1
0
mirror of https://github.com/moparisthebest/curl synced 2024-12-22 08:08:50 -05:00

Fix TELNET transfers not being aborted upon write callback failures

This commit is contained in:
Yang Tse 2009-03-12 13:18:25 +00:00
parent d15b8273d6
commit fa96436661
3 changed files with 33 additions and 10 deletions

View File

@ -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.

View File

@ -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:

View File

@ -108,7 +108,7 @@ static CURLcode check_wsock2 ( struct SessionHandle *data );
#endif
static
void telrcv(struct connectdata *,
CURLcode telrcv(struct connectdata *,
const unsigned char *inbuf, /* Data received from socket */
ssize_t count); /* Number of bytes received */
@ -952,19 +952,26 @@ static void suboption(struct connectdata *conn)
}
static
void telrcv(struct connectdata *conn,
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