]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
telnet: replace atoi for BINARY handling with curlx_str_number
authorDaniel Stenberg <daniel@haxx.se>
Wed, 12 Nov 2025 07:32:31 +0000 (08:32 +0100)
committerDaniel Stenberg <daniel@haxx.se>
Wed, 12 Nov 2025 09:41:52 +0000 (10:41 +0100)
Also, only consider 0 to be a valid switch-off. Previously any value
except 1 had the same effect.

Closes #19477

lib/telnet.c

index 232e56a8849af4a716b40305a1d04415e971a2a4..a939ae1a73f849db195a9d207bd68e6db56d747f 100644 (file)
@@ -895,8 +895,10 @@ static CURLcode check_telnet_options(struct Curl_easy *data,
       case 6:
         /* To take care or not of the 8th bit in data exchange */
         if(curl_strnequal(option, "BINARY", 6)) {
-          int binary_option = atoi(arg);
-          if(binary_option != 1) {
+          const char *p = arg;
+          curl_off_t binary_option;
+          if(!curlx_str_number(&p, &binary_option, 1) &&
+             (binary_option != 1)) {
             tn->us_preferred[CURL_TELOPT_BINARY] = CURL_NO;
             tn->him_preferred[CURL_TELOPT_BINARY] = CURL_NO;
           }