fixes for compress handling

This commit is contained in:
Sean Middleditch 2009-03-21 01:07:18 -04:00
parent e5327da4f5
commit 8c5673535a
1 changed files with 7 additions and 6 deletions

View File

@ -605,6 +605,10 @@ static void _process(telnet_t *telnet, const char *buffer, size_t size) {
switch (byte) { switch (byte) {
/* end subnegotiation */ /* end subnegotiation */
case TELNET_SE: case TELNET_SE:
/* return to default state */
start = i + 1;
telnet->state = TELNET_STATE_DATA;
/* process subnegotiation */ /* process subnegotiation */
if (_subnegotiate(telnet) != 0) { if (_subnegotiate(telnet) != 0) {
/* any remaining bytes in the buffer are compressed. /* any remaining bytes in the buffer are compressed.
@ -613,13 +617,9 @@ static void _process(telnet_t *telnet, const char *buffer, size_t size) {
* remaining compressed bytes in the current _process * remaining compressed bytes in the current _process
* buffer argument * buffer argument
*/ */
telnet_recv(telnet, &buffer[i + 1], size - start); telnet_recv(telnet, &buffer[start], size - start);
return; return;
} }
/* return to default state */
start = i + 1;
telnet->state = TELNET_STATE_DATA;
break; break;
/* escaped IAC byte */ /* escaped IAC byte */
case TELNET_IAC: case TELNET_IAC:
@ -649,7 +649,7 @@ static void _process(telnet_t *telnet, const char *buffer, size_t size) {
* TELNET_STATE_SB_DATA_IAC about invoking telnet_recv() * TELNET_STATE_SB_DATA_IAC about invoking telnet_recv()
*/ */
if (_subnegotiate(telnet) != 0) { if (_subnegotiate(telnet) != 0) {
telnet_recv(telnet, &buffer[i + 1], size - start); telnet_recv(telnet, &buffer[i + 1], size - i - 1);
return; return;
} }
@ -658,6 +658,7 @@ static void _process(telnet_t *telnet, const char *buffer, size_t size) {
* that would be gross. * that would be gross.
*/ */
telnet->state = TELNET_STATE_IAC; telnet->state = TELNET_STATE_IAC;
start = i + 1;
_process(telnet, (char *)&byte, 1); _process(telnet, (char *)&byte, 1);
break; break;
} }