[PATCH] Bad behavior on disconnect
Brought to you by:
crigler
When client disconnects uncleanly, it might happen that an underlying
read() operation returns with an error. This error was interpreted
wrongly because the negative return value was assigned to a variable
of unsigned type and being checked for <= 0. As this condition does
not hold in error case, a packet with wrong len (255) was sent instead
of aborting the client:
| read(0, 0x7fffa6dcfb12, 8) = -1 EIO (Input/output error)
| write(3, "\0\377\0\0\0\0\0\0\0\0", 10) = 10
For reference, the 'pkt' is defined as
| struct packet
| {
| unsigned char type;
| unsigned char len;
| ...
| }
I have updated CVS. Please take a look and confirm that this is fixed now.