Wireshark-users: Re: [Wireshark-users] TCP Decoding differences between Ethereal0.99 and Wireshar

From: Guy Harris <guy@xxxxxxxxxxxx>
Date: Thu, 02 Nov 2006 09:31:29 -0800
Joerg Mayer wrote:

Please let me know whether the fix is OK so I may close the bug (I know that
it fixes the sample capture attached to 1043).

It looks correct.

(In C, "i" will have, at that point, the value it had when the loop was exited, and the only way the loop before that point can be exited is if i >= nchars - which means if i == nchars, as it's an integer and being stepped by 1. "i" will be 1 position past the last character in the buffer, so buffer[--i] = '\n' will overwrite it and buffer[i] = '\n' will append to it, which is what we want.

nchars will be no bigger than FLT_BUF_SIZE, and the buffer is 1 bigger than FLT_BUF_SIZE, so that's safe.)