fixed possible buffer overflow in tcp client

The tcp client receives a buffer of maximum length
and then sets the end to null to make sure it is terminated.
But it assigns to the offset at the length of the result
which could be one past the end of the buffer.
Fixed by receiving one less than the maximum length.