This fixes the issue that was reported - but this code is weird.  It is reading a character at a time.
There isn't really any reason to use an input buffer of size 1024.

Also the wrapping that occurs when len > 1023 means that the data in inbuf[0..7] can be corrupted by an invalid request.

Similarly why does outbuff use a 1024 byte buffer when only 8 bytes are used as far as I can see.

The memsets, and other code should be using sizeof(outbuff), or a predefined constant - e.g., SOCKS_HEADER_SIZE