mirror of
https://github.com/moparisthebest/curl
synced 2024-12-21 23:58:49 -05:00
Fix TELNET transfers not being aborted upon write callback failures
This commit is contained in:
parent
d15b8273d6
commit
fa96436661
6
CHANGES
6
CHANGES
@ -6,6 +6,12 @@
|
||||
|
||||
Changelog
|
||||
|
||||
Yang Tse (12 Mar 2009)
|
||||
- Added missing Curl_read() return code checking in TELNET transfers.
|
||||
|
||||
- Pierre Brico found and fixed TELNET transfers not being aborted upon
|
||||
a write callback failure.
|
||||
|
||||
Daniel Stenberg (11 Mar 2009)
|
||||
- Kamil Dudka made the curl tool properly call curl_global_init() before any
|
||||
other libcurl function.
|
||||
|
@ -19,6 +19,7 @@ This release includes the following bugfixes:
|
||||
o an alloc-related call in the OpenSSL-using code didn't check the return value
|
||||
o curl_easy_duphandle() failed to duplicate cookies at times
|
||||
o missing TELNET timeout support in Windows builds
|
||||
o missing Curl_read() and write callback result checking in TELNET transfers
|
||||
|
||||
This release includes the following known bugs:
|
||||
|
||||
|
36
lib/telnet.c
36
lib/telnet.c
@ -108,9 +108,9 @@ static CURLcode check_wsock2 ( struct SessionHandle *data );
|
||||
#endif
|
||||
|
||||
static
|
||||
void telrcv(struct connectdata *,
|
||||
const unsigned char *inbuf, /* Data received from socket */
|
||||
ssize_t count); /* Number of bytes received */
|
||||
CURLcode telrcv(struct connectdata *,
|
||||
const unsigned char *inbuf, /* Data received from socket */
|
||||
ssize_t count); /* Number of bytes received */
|
||||
|
||||
#ifndef CURL_DISABLE_VERBOSE_STRINGS
|
||||
static void printoption(struct SessionHandle *data,
|
||||
@ -952,19 +952,26 @@ static void suboption(struct connectdata *conn)
|
||||
}
|
||||
|
||||
static
|
||||
void telrcv(struct connectdata *conn,
|
||||
const unsigned char *inbuf, /* Data received from socket */
|
||||
ssize_t count) /* Number of bytes received */
|
||||
CURLcode telrcv(struct connectdata *conn,
|
||||
const unsigned char *inbuf, /* Data received from socket */
|
||||
ssize_t count) /* Number of bytes received */
|
||||
{
|
||||
unsigned char c;
|
||||
CURLcode result;
|
||||
int in = 0;
|
||||
int startwrite=-1;
|
||||
struct SessionHandle *data = conn->data;
|
||||
struct TELNET *tn = (struct TELNET *)data->state.proto.telnet;
|
||||
|
||||
#define startskipping() \
|
||||
if(startwrite >= 0) \
|
||||
Curl_client_write(conn, CLIENTWRITE_BODY, (char *)&inbuf[startwrite], in-startwrite); \
|
||||
if(startwrite >= 0) { \
|
||||
result = Curl_client_write(conn, \
|
||||
CLIENTWRITE_BODY, \
|
||||
(char *)&inbuf[startwrite], \
|
||||
in-startwrite); \
|
||||
if(result != CURLE_OK) \
|
||||
return result; \
|
||||
} \
|
||||
startwrite = -1
|
||||
|
||||
#define writebyte() \
|
||||
@ -1119,6 +1126,7 @@ void telrcv(struct connectdata *conn,
|
||||
++in;
|
||||
}
|
||||
bufferflush();
|
||||
return CURLE_OK;
|
||||
}
|
||||
|
||||
/* Escape and send a telnet data block */
|
||||
@ -1389,7 +1397,11 @@ static CURLcode telnet_do(struct connectdata *conn, bool *done)
|
||||
break;
|
||||
}
|
||||
|
||||
telrcv(conn, (unsigned char *)buf, nread);
|
||||
code = telrcv(conn, (unsigned char *)buf, nread);
|
||||
if(code) {
|
||||
keepon = FALSE;
|
||||
break;
|
||||
}
|
||||
|
||||
fflush(stdout);
|
||||
|
||||
@ -1475,7 +1487,11 @@ static CURLcode telnet_do(struct connectdata *conn, bool *done)
|
||||
break;
|
||||
}
|
||||
|
||||
telrcv(conn, (unsigned char *)buf, nread);
|
||||
code = telrcv(conn, (unsigned char *)buf, nread);
|
||||
if(code) {
|
||||
keepon = FALSE;
|
||||
break;
|
||||
}
|
||||
|
||||
/* Negotiate if the peer has started negotiating,
|
||||
otherwise don't. We don't want to speak telnet with
|
||||
|
Loading…
Reference in New Issue
Block a user