1
0
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:
Yang Tse 2010-02-04 17:17:19 +00:00
parent 1a5749424b
commit f47b84b57f
4 changed files with 50 additions and 5 deletions

View File

@ -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++;
}
}

View File

@ -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++;
}
}

View File

@ -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++;
}
}

View File

@ -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++;
}
}