Fix the buffer overflow issue when reading socket data