chandrasis / php-handlersocket

Automatically exported from code.google.com/p/php-handlersocket
0 stars 0 forks source link

Long result will be randomly dropped #34

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. Keep read many records with executeSingle (make sure the size of result over 
4096 or HS_SOCKET_BLOCK_SIZE bytes)
2. Randomly get truncated result (only 4096 or HS_SOCKET_BLOCK_SIZE bytes got)

What is the expected output? What do you see instead?
Full result will be fetched no match how large of the socket packet.

What version of the product are you using? On what operating system?
0.3.1

Please provide any additional information below.
When the result is larger than HS_SOCKET_BLOCK_SIZE, a do-while loop in 
function hs_response_value at handlersocket.c:1532~1600 will handle all 
segments of the result.

At line 1595:
if (recv[j] == HS_CODE_EOL)
{
    break;
}
if all 4096 or HS_SOCKET_BLOCK_SIZE bytes are data, j will then be equal to 
4096 which is undefined value, if this undefined value just equal to 
HS_CODE_EOL, the do-while loop will be break, so the result is truncated.

To fix this, add:
recv[block_size] = '\0';
at line 1348 to make sure recv[HS_SOCKET_BLOCK_SIZE] defined.

Original issue reported on code.google.com by aludirks...@gmail.com on 24 Oct 2014 at 6:52