mirror of
https://github.com/moparisthebest/curl
synced 2024-12-22 08:08:50 -05:00
Validate server port argument
This commit is contained in:
parent
1a5749424b
commit
f47b84b57f
@ -1174,7 +1174,16 @@ int main(int argc, char *argv[])
|
||||
else if(!strcmp("--port", argv[arg])) {
|
||||
arg++;
|
||||
if(argc>arg) {
|
||||
port = (unsigned short)atoi(argv[arg]);
|
||||
char *endptr;
|
||||
long lnum = -1;
|
||||
lnum = strtol(argv[arg], &endptr, 10);
|
||||
if((endptr != argv[arg] + strlen(argv[arg])) ||
|
||||
(lnum < 1025L) || (lnum > 65535L)) {
|
||||
fprintf(stderr, "rtspd: invalid --port argument (%s)\n",
|
||||
argv[arg]);
|
||||
return 0;
|
||||
}
|
||||
port = (unsigned short)(lnum & 0xFFFFL);
|
||||
arg++;
|
||||
}
|
||||
}
|
||||
|
@ -890,7 +890,16 @@ int main(int argc, char *argv[])
|
||||
else if(!strcmp("--port", argv[arg])) {
|
||||
arg++;
|
||||
if(argc>arg) {
|
||||
port = (unsigned short)atoi(argv[arg]);
|
||||
char *endptr;
|
||||
long lnum = -1;
|
||||
lnum = strtol(argv[arg], &endptr, 10);
|
||||
if((endptr != argv[arg] + strlen(argv[arg])) ||
|
||||
((lnum != 0L) && ((lnum < 1025L) || (lnum > 65535L)))) {
|
||||
fprintf(stderr, "sockfilt: invalid --port argument (%s)\n",
|
||||
argv[arg]);
|
||||
return 0;
|
||||
}
|
||||
port = (unsigned short)(lnum & 0xFFFFL);
|
||||
arg++;
|
||||
}
|
||||
}
|
||||
@ -899,7 +908,16 @@ int main(int argc, char *argv[])
|
||||
doing a passive server-style listening. */
|
||||
arg++;
|
||||
if(argc>arg) {
|
||||
connectport = (unsigned short)atoi(argv[arg]);
|
||||
char *endptr;
|
||||
long lnum = -1;
|
||||
lnum = strtol(argv[arg], &endptr, 10);
|
||||
if((endptr != argv[arg] + strlen(argv[arg])) ||
|
||||
(lnum < 1025L) || (lnum > 65535L)) {
|
||||
fprintf(stderr, "sockfilt: invalid --connect argument (%s)\n",
|
||||
argv[arg]);
|
||||
return 0;
|
||||
}
|
||||
connectport = (unsigned short)(lnum & 0xFFFFL);
|
||||
arg++;
|
||||
}
|
||||
}
|
||||
|
@ -1082,7 +1082,16 @@ int main(int argc, char *argv[])
|
||||
else if(!strcmp("--port", argv[arg])) {
|
||||
arg++;
|
||||
if(argc>arg) {
|
||||
port = (unsigned short)atoi(argv[arg]);
|
||||
char *endptr;
|
||||
long lnum = -1;
|
||||
lnum = strtol(argv[arg], &endptr, 10);
|
||||
if((endptr != argv[arg] + strlen(argv[arg])) ||
|
||||
(lnum < 1025L) || (lnum > 65535L)) {
|
||||
fprintf(stderr, "sws: invalid --port argument (%s)\n",
|
||||
argv[arg]);
|
||||
return 0;
|
||||
}
|
||||
port = (unsigned short)(lnum & 0xFFFFL);
|
||||
arg++;
|
||||
}
|
||||
}
|
||||
|
@ -708,7 +708,16 @@ int main(int argc, char **argv)
|
||||
else if(!strcmp("--port", argv[arg])) {
|
||||
arg++;
|
||||
if(argc>arg) {
|
||||
port = (unsigned short)atoi(argv[arg]);
|
||||
char *endptr;
|
||||
long lnum = -1;
|
||||
lnum = strtol(argv[arg], &endptr, 10);
|
||||
if((endptr != argv[arg] + strlen(argv[arg])) ||
|
||||
(lnum < 1025L) || (lnum > 65535L)) {
|
||||
fprintf(stderr, "tftpd: invalid --port argument (%s)\n",
|
||||
argv[arg]);
|
||||
return 0;
|
||||
}
|
||||
port = (unsigned short)(lnum & 0xFFFFL);
|
||||
arg++;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user