fix buffer overflow when sending large data.