diff options
author | Thomas E. Dickey <dickey@invisible-island.net> | 1999-10-21 15:30:04 -0400 |
---|---|---|
committer | Thomas E. Dickey <dickey@invisible-island.net> | 1999-10-21 15:30:04 -0400 |
commit | 2d161b7d97cebd6f38885cf69933291fec6b4381 (patch) | |
tree | 47b7f706656bad14ad80a021a27332ca96d4684e /WWW/Library/Implementation/HTTCP.c | |
parent | faba82cd3507fcd4172d94209cd1b700689d5d35 (diff) | |
download | lynx-snapshots-2d161b7d97cebd6f38885cf69933291fec6b4381.tar.gz |
snapshot of project "lynx", label v2-8-3dev_13
Diffstat (limited to 'WWW/Library/Implementation/HTTCP.c')
-rw-r--r-- | WWW/Library/Implementation/HTTCP.c | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/WWW/Library/Implementation/HTTCP.c b/WWW/Library/Implementation/HTTCP.c index 9bd4bcd3..18de1134 100644 --- a/WWW/Library/Implementation/HTTCP.c +++ b/WWW/Library/Implementation/HTTCP.c @@ -1180,6 +1180,7 @@ PUBLIC int HTParseInet ARGS2( { char *port; int dotcount_ip = 0; /* for dotted decimal IP addr */ + char *strptr; #ifndef _WINDOWS_NSL char *host = NULL; #endif /* _WINDOWS_NSL */ @@ -1203,17 +1204,18 @@ PUBLIC int HTParseInet ARGS2( */ if ((port = strchr(host, ':')) != NULL) { *port++ = 0; /* Chop off port */ + strptr = port; if (port[0] >= '0' && port[0] <= '9') { #ifdef UNIX - soc_in->sin_port = htons(atol(port)); + soc_in->sin_port = htons(strtol(port, &strptr, 10)); #else /* VMS: */ #ifdef DECNET - soc_in->sdn_objnum = (unsigned char)(strtol(port, (char**)0, 10)); + soc_in->sdn_objnum = (unsigned char)(strtol(port, &strptr, 10)); #else - soc_in->sin_port = htons((unsigned short)strtol(port,(char**)0,10)); + soc_in->sin_port = htons((unsigned short)strtol(port,&strptr,10)); #endif /* Decnet */ #endif /* Unix vs. VMS */ -#ifdef SUPPRESS /* 1. crashes!?!. 2. Not recommended */ +#ifdef SUPPRESS /* 1. crashes!?!. 2. URL syntax has number not name */ } else { struct servent * serv = getservbyname(port, (char*)0); if (serv) { @@ -1223,6 +1225,13 @@ PUBLIC int HTParseInet ARGS2( } #endif /* SUPPRESS */ } + if (strptr && *strptr != '\0') { +#ifndef _WINDOWS_NSL + FREE(host); +#endif /* _WINDOWS_NSL */ + HTAlwaysAlert(NULL, gettext("Address has invalid port")); + return -1; + } } #ifdef DECNET @@ -1237,7 +1246,7 @@ PUBLIC int HTParseInet ARGS2( #else /* parse Internet host: */ if (*host >= '0' && *host <= '9') { /* Test for numeric node address: */ - char *strptr = host; + strptr = host; while (*strptr) { if (*strptr == '.') { dotcount_ip++; |