summaryrefslogtreecommitdiff
path: root/libs/libcurl/src/telnet.c
diff options
context:
space:
mode:
Diffstat (limited to 'libs/libcurl/src/telnet.c')
-rw-r--r--libs/libcurl/src/telnet.c47
1 files changed, 23 insertions, 24 deletions
diff --git a/libs/libcurl/src/telnet.c b/libs/libcurl/src/telnet.c
index f57addbefe..fa475fc4e2 100644
--- a/libs/libcurl/src/telnet.c
+++ b/libs/libcurl/src/telnet.c
@@ -58,6 +58,7 @@
#include "select.h"
#include "strcase.h"
#include "warnless.h"
+#include "strparse.h"
/* The last 3 #include files should be in this order */
#include "curl_printf.h"
@@ -862,22 +863,20 @@ static CURLcode check_telnet_options(struct Curl_easy *data)
case 2:
/* Window Size */
if(strncasecompare(option, "WS", 2)) {
- char *p;
- unsigned long x = strtoul(arg, &p, 10);
- unsigned long y = 0;
- if(x && (x <= 0xffff) && Curl_raw_tolower(*p) == 'x') {
- p++;
- y = strtoul(p, NULL, 10);
- if(y && (y <= 0xffff)) {
- tn->subopt_wsx = (unsigned short)x;
- tn->subopt_wsy = (unsigned short)y;
- tn->us_preferred[CURL_TELOPT_NAWS] = CURL_YES;
- }
- }
- if(!y) {
+ const char *p = arg;
+ curl_off_t x = 0;
+ curl_off_t y = 0;
+ if(Curl_str_number(&p, &x, 0xffff) ||
+ Curl_str_single(&p, 'x') ||
+ Curl_str_number(&p, &y, 0xffff)) {
failf(data, "Syntax error in telnet option: %s", head->data);
result = CURLE_SETOPT_OPTION_SYNTAX;
}
+ else {
+ tn->subopt_wsx = (unsigned short)x;
+ tn->subopt_wsy = (unsigned short)y;
+ tn->us_preferred[CURL_TELOPT_NAWS] = CURL_YES;
+ }
}
else
result = CURLE_UNKNOWN_OPTION;
@@ -1067,15 +1066,15 @@ CURLcode telrcv(struct Curl_easy *data,
int startwrite = -1;
struct TELNET *tn = data->req.p.telnet;
-#define startskipping() \
- if(startwrite >= 0) { \
- result = Curl_client_write(data, \
- CLIENTWRITE_BODY, \
- (char *)&inbuf[startwrite], \
- in-startwrite); \
- if(result) \
- return result; \
- } \
+#define startskipping() \
+ if(startwrite >= 0) { \
+ result = Curl_client_write(data, \
+ CLIENTWRITE_BODY, \
+ (const char *)&inbuf[startwrite], \
+ in-startwrite); \
+ if(result) \
+ return result; \
+ } \
startwrite = -1
#define writebyte() \
@@ -1450,7 +1449,7 @@ static CURLcode telnet_do(struct Curl_easy *data, bool *done)
events.lNetworkEvents = 0;
if(WSAEnumNetworkEvents(sockfd, event_handle, &events) == SOCKET_ERROR) {
err = SOCKERRNO;
- if(err != EINPROGRESS) {
+ if(err != SOCKEINPROGRESS) {
infof(data, "WSAEnumNetworkEvents failed (%d)", err);
keepon = FALSE;
result = CURLE_READ_ERROR;
@@ -1555,7 +1554,7 @@ static CURLcode telnet_do(struct Curl_easy *data, bool *done)
/* In test 1452, macOS sees a ECONNRESET sometimes? Is this the
* telnet test server not shutting down the socket in a clean way?
* Seems to be timing related, happens more on slow debug build */
- if(data->state.os_errno == ECONNRESET) {
+ if(data->state.os_errno == SOCKECONNRESET) {
DEBUGF(infof(data, "telnet_do, unexpected ECONNRESET on recv"));
}
break;