tests/server: replace atoi() and atol() with curlx_str_number()

Closes #19510
This commit is contained in:
Viktor Szakats 2025-11-13 12:46:59 +01:00
parent 833c429627
commit bb1391f943
No known key found for this signature in database
GPG key ID: B5ABD165E2AEF201
9 changed files with 141 additions and 62 deletions

View file

@ -1240,6 +1240,8 @@ static int test_sockfilt(int argc, char *argv[])
server_port = 8999;
while(argc > arg) {
const char *opt;
curl_off_t num;
if(!strcmp("--version", argv[arg])) {
printf("sockfilt IPv4%s\n",
#ifdef USE_IPV6
@ -1291,7 +1293,9 @@ static int test_sockfilt(int argc, char *argv[])
else if(!strcmp("--port", argv[arg])) {
arg++;
if(argc > arg) {
server_port = (unsigned short)atol(argv[arg]);
opt = argv[arg];
if(!curlx_str_number(&opt, &num, 0xffff))
server_port = (unsigned short)num;
arg++;
}
}
@ -1300,13 +1304,13 @@ static int test_sockfilt(int argc, char *argv[])
doing a passive server-style listening. */
arg++;
if(argc > arg) {
int inum = atoi(argv[arg]);
if(inum && ((inum < 1025) || (inum > 65535))) {
opt = argv[arg];
if(curlx_str_number(&opt, &num, 0xffff) || num < 1025) {
fprintf(stderr, "sockfilt: invalid --connect argument (%s)\n",
argv[arg]);
return 0;
}
server_connectport = (unsigned short)inum;
server_connectport = (unsigned short)num;
arg++;
}
}