mirror of
https://github.com/curl/curl.git
synced 2026-04-14 22:41:40 +03:00
tests/server: replace atoi() and atol() with curlx_str_number()
Closes #19510
This commit is contained in:
parent
833c429627
commit
bb1391f943
9 changed files with 141 additions and 62 deletions
|
|
@ -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++;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue