diff options
Diffstat (limited to 'WWW/Library/Implementation')
-rw-r--r-- | WWW/Library/Implementation/HTAccess.c | 2 | ||||
-rw-r--r-- | WWW/Library/Implementation/HTFTP.c | 71 | ||||
-rw-r--r-- | WWW/Library/Implementation/HTFile.c | 5 | ||||
-rw-r--r-- | WWW/Library/Implementation/HTTCP.c | 147 | ||||
-rw-r--r-- | WWW/Library/Implementation/HTTP.c | 4 | ||||
-rw-r--r-- | WWW/Library/Implementation/HTUtils.h | 8 | ||||
-rw-r--r-- | WWW/Library/Implementation/SGML.c | 2 | ||||
-rw-r--r-- | WWW/Library/Implementation/makefile.in | 1 |
8 files changed, 102 insertions, 138 deletions
diff --git a/WWW/Library/Implementation/HTAccess.c b/WWW/Library/Implementation/HTAccess.c index 962407da..86a3bf9e 100644 --- a/WWW/Library/Implementation/HTAccess.c +++ b/WWW/Library/Implementation/HTAccess.c @@ -357,7 +357,7 @@ PUBLIC BOOL override_proxy ARGS1( #ifdef CJK_EX /* ASATAKU PROXY HACK */ if ((!templ_port || templ_port == port) && (t_len > 0 && t_len <= h_len && - isdigit(*no_proxy) && !strncmp(host, no_proxy, t_len))) { + isdigit(UCH(*no_proxy)) && !strncmp(host, no_proxy, t_len))) { FREE(host); return YES; } diff --git a/WWW/Library/Implementation/HTFTP.c b/WWW/Library/Implementation/HTFTP.c index 49983c79..8f68cf6b 100644 --- a/WWW/Library/Implementation/HTFTP.c +++ b/WWW/Library/Implementation/HTFTP.c @@ -1311,21 +1311,21 @@ PRIVATE int get_listen_socket NOARGS } #endif /* INET6 */ -/* Inform TCP that we will accept connections -*/ - { - int status; + /* Inform TCP that we will accept connections + */ + { + int status; #ifdef SOCKS - if (socks_flag) - status = Rlisten(master_socket, 1); - else + if (socks_flag) + status = Rlisten(master_socket, 1); + else #endif /* SOCKS */ - status = listen(master_socket, 1); - if (status < 0) { - master_socket = -1; - return HTInetStatus("listen"); + status = listen(master_socket, 1); + if (status < 0) { + master_socket = -1; + return HTInetStatus("listen"); + } } - } CTRACE((tfp, "TCP: Master socket(), bind() and listen() all OK\n")); FD_SET(master_socket, &open_sockets); if ((master_socket+1) > num_sockets) @@ -2998,18 +2998,21 @@ PUBLIC int HTFTPLoad ARGS4( CTRACE((tfp, "HTFTP: Port defined.\n")); #endif /* REPEAT_PORT */ } else { /* Tell the server to be passive */ - char command[LINE_LENGTH+1]; + char *command = NULL; char *p; int h0, h1, h2, h3, p0, p1; /* Parts of reply */ +#ifdef INET6 + char dst[LINE_LENGTH+1]; +#endif data_soc = status; #ifdef INET6 - status = send_cmd_1("EPSV"); + status = send_cmd_1(p = "EPSV"); if (status < 0) /* retry or Bad return */ continue; else if (status != 2) { - status = send_cmd_1("PASV"); + status = send_cmd_1(p = "PASV"); if (status < 0) /* retry or Bad return */ continue; else if (status != 2) { @@ -3017,7 +3020,7 @@ PUBLIC int HTFTPLoad ARGS4( } } - if (strncmp(command, "PASV", 4) == 0) { + if (strcmp(p, "PASV") == 0) { for (p = response_text; *p && *p != ','; p++) ; /* null body */ @@ -3030,26 +3033,37 @@ PUBLIC int HTFTPLoad ARGS4( return -99; } passive_port = (p0<<8) + p1; - } else if (strncmp(command, "EPSV", 4) == 0) { + snprintf(dst, sizeof(dst), "%d.%d.%d.%d", h0, h1, h2, h3); + } else if (strcmp(p, "EPSV") == 0) { unsigned char c0, c1, c2, c3; + struct sockaddr_storage ss; + int sslen; + /* - * EPSV |||port| + * EPSV bla (|||port|) */ for (p = response_text; *p && !isspace(*p); p++) ; /* null body */ - for (p = response_text; *p && isspace(*p); p++) + for (/*nothing*/; *p && *p && *p != '('; p++) /*)*/ ; /* null body */ - status = sscanf(p+1, "%c%c%c%d%c", - &c0, &c1, &c2, &p0, &c3); + status = sscanf(p, "(%c%c%c%d%c)", &c0, &c1, &c2, &p0, &c3); if (status != 5) { fprintf(tfp, "HTFTP: EPSV reply has invalid format!\n"); return -99; } - h0 = c0; - h1 = c1; - h2 = c2; - h3 = c3; passive_port = p0; + + sslen = sizeof(ss); + if (getpeername(control->socket, (struct sockaddr *)&ss, + &sslen) < 0) { + fprintf(tfp, "HTFTP: getpeername(control) failed\n"); + return -99; + } + if (getnameinfo((struct sockaddr *)&ss, sslen, dst, + sizeof(dst), NULL, 0, NI_NUMERICHOST)) { + fprintf(tfp, "HTFTP: getnameinfo failed\n"); + return -99; + } } #else status = send_cmd_1("PASV"); @@ -3077,9 +3091,14 @@ PUBLIC int HTFTPLoad ARGS4( /* Open connection for data: */ - sprintf(command, "ftp://%d.%d.%d.%d:%d/", +#ifdef INET6 + HTSprintf0(&command, "ftp://%s:%d/", dst, passive_port); +#else + HTSprintf0(&command, "ftp://%d.%d.%d.%d:%d/", h0, h1, h2, h3, passive_port); +#endif status = HTDoConnect(command, "FTP data", passive_port, &data_soc); + FREE(command); if (status < 0) { (void) HTInetStatus(gettext("connect for data")); diff --git a/WWW/Library/Implementation/HTFile.c b/WWW/Library/Implementation/HTFile.c index 3e990097..0fbbbde7 100644 --- a/WWW/Library/Implementation/HTFile.c +++ b/WWW/Library/Implementation/HTFile.c @@ -2025,11 +2025,10 @@ PUBLIC int HTStat ARGS2( */ if (access(temp_name, 0) == 0) { if (stat(temp_name, data) == -1) data->st_mode = S_IFDIR; - return 0; + result = 0; } - return -1; #else - return stat(temp_name, data); + result = stat(temp_name, data); #endif if (temp_name != filename) { diff --git a/WWW/Library/Implementation/HTTCP.c b/WWW/Library/Implementation/HTTCP.c index c4fae8f2..93c1b18d 100644 --- a/WWW/Library/Implementation/HTTCP.c +++ b/WWW/Library/Implementation/HTTCP.c @@ -44,7 +44,7 @@ PUBLIC int BSDselect PARAMS(( fd_set * readfds, fd_set * writefds, fd_set * exceptfds, - struct timeval * timeout)); + struct timeval * select_timeout)); #ifdef select #undef select #endif /* select */ @@ -462,11 +462,20 @@ PRIVATE void dump_hostent ARGS2( ** See also description of LYGetHostByName. */ #ifdef NSL_FORK + +#define REHOSTENT_SIZE 128 /* not bigger than pipe buffer! */ + +typedef struct { + struct hostent h; + char rest[REHOSTENT_SIZE]; + } AlignedHOSTENT; + PRIVATE size_t fill_rehostent ARGS3( char *, rehostent, size_t, rehostentsize, CONST struct hostent *, phost) { + AlignedHOSTENT *data = (AlignedHOSTENT *)rehostent; int num_addrs = 0; int num_aliases = 0; char **pcnt; @@ -526,8 +535,8 @@ PRIVATE size_t fill_rehostent ARGS3( } } - ((struct hostent *)rehostent)->h_addrtype = phost->h_addrtype; - ((struct hostent *)rehostent)->h_length = phost->h_length; + data->h.h_addrtype = phost->h_addrtype; + data->h.h_length = phost->h_length; p_next_charptr = (char **)(rehostent + curlen); p_next_char = rehostent + curlen; if (phost->h_addr_list) @@ -536,7 +545,7 @@ PRIVATE size_t fill_rehostent ARGS3( p_next_char += (num_aliases+1) * sizeof(phost->h_aliases[0]); if (phost->h_addr_list) { - ((struct hostent *)rehostent)->h_addr_list = p_next_charptr; + data->h.h_addr_list = p_next_charptr; for (pcnt=phost->h_addr_list, i_addr = 0; i_addr < num_addrs; pcnt++, i_addr++) { @@ -546,11 +555,11 @@ PRIVATE size_t fill_rehostent ARGS3( } *p_next_charptr++ = NULL; } else { - ((struct hostent *)rehostent)->h_addr_list = NULL; + data->h.h_addr_list = NULL; } if (phost->h_name) { - ((struct hostent *)rehostent)->h_name = p_next_char; + data->h.h_name = p_next_char; if (name_len) { strcpy(p_next_char, phost->h_name); p_next_char += name_len + 1; @@ -558,11 +567,11 @@ PRIVATE size_t fill_rehostent ARGS3( *p_next_char++ = '\0'; } } else { - ((struct hostent *)rehostent)->h_name = NULL; + data->h.h_name = NULL; } if (phost->h_aliases) { - ((struct hostent *)rehostent)->h_aliases = p_next_charptr; + data->h.h_aliases = p_next_charptr; for (pcnt=phost->h_aliases, i_alias = 0; (*pcnt && i_alias < num_addrs); pcnt++, i_alias++) { @@ -580,15 +589,13 @@ PRIVATE size_t fill_rehostent ARGS3( } *p_next_charptr++ = NULL; } else { - ((struct hostent *)rehostent)->h_aliases = NULL; + data->h.h_aliases = NULL; } curlen = p_next_char - (char *)rehostent; return curlen; } #endif /* NSL_FORK */ -#define REHOSTENT_SIZE 128 /* not bigger than pipe buffer! */ - #ifndef HAVE_H_ERRNO #undef h_errno #define h_errno my_errno @@ -641,10 +648,7 @@ PUBLIC struct hostent * LYGetHostByName ARGS1( #endif #ifdef NSL_FORK /* for transfer of result between from child to parent: */ - static struct { - struct hostent h; - char rest[REHOSTENT_SIZE]; - } aligned_full_rehostent; + static AlignedHOSTENT aligned_full_rehostent; /* * We could define rehosten directly as a * static char rehostent[REHOSTENT_SIZE], @@ -738,7 +742,7 @@ PUBLIC struct hostent * LYGetHostByName ARGS1( #endif time_t start_time = time((time_t *)0); fd_set readfds; - struct timeval timeout; + struct timeval one_second; long dns_patience = 30; /* how many seconds will we wait for DNS? */ int child_exited = 0; @@ -930,8 +934,8 @@ PUBLIC struct hostent * LYGetHostByName ARGS1( } } - timeout.tv_sec = 1; - timeout.tv_usec = 0; + one_second.tv_sec = 1; + one_second.tv_usec = 0; FD_SET(pfd[0], &readfds); /* @@ -941,10 +945,10 @@ PUBLIC struct hostent * LYGetHostByName ARGS1( */ #ifdef SOCKS if (socks_flag) - selret = Rselect(pfd[0] + 1, (void *)&readfds, NULL, NULL, &timeout); + selret = Rselect(pfd[0] + 1, (void *)&readfds, NULL, NULL, &one_second); else #endif /* SOCKS */ - selret = select(pfd[0] + 1, (void *)&readfds, NULL, NULL, &timeout); + selret = select(pfd[0] + 1, (void *)&readfds, NULL, NULL, &one_second); if ((selret > 0) && FD_ISSET(pfd[0], &readfds)) { /* @@ -1173,24 +1177,14 @@ failed: ** *soc_in is filled in. If no port is specified in str, that ** field is left unchanged in *soc_in. */ -#ifdef INET6 -PRIVATE int HTParseInet ARGS3( - SockA *, soc_in, - CONST char *, str, - int, default_port) -#else +#ifndef INET6 PRIVATE int HTParseInet ARGS2( SockA *, soc_in, CONST char *, str) -#endif /* INET6 */ { char *port; -#ifdef INET6 - char portstr[NI_MAXSERV]; -#else int dotcount_ip = 0; /* for dotted decimal IP addr */ char *strptr; -#endif #ifndef _WINDOWS_NSL char *host = NULL; #endif /* _WINDOWS_NSL */ @@ -1212,20 +1206,6 @@ PRIVATE int HTParseInet ARGS2( /* ** Parse port number if present. */ -#ifdef INET6 - if (!strrchr(host, ']')) - port = strrchr(host, ':'); - else - port = strrchr(strrchr(host, ']'), ':'); - - if (port) { - *port++ = 0; /* Chop off port */ - } - else { - sprintf(portstr,"%d", default_port); - port = portstr; - } -#else if ((port = strchr(host, ':')) != NULL) { *port++ = 0; /* Chop off port */ strptr = port; @@ -1257,7 +1237,6 @@ PRIVATE int HTParseInet ARGS2( return -1; } } -#endif /* INET6 */ #ifdef DECNET /* @@ -1270,13 +1249,6 @@ PRIVATE int HTParseInet ARGS2( soc_in->sdn_objnum, host)); #else /* parse Internet host: */ -#ifdef INET6 - /* [host] case */ - if (host[0] == '[' && host[strlen(host) - 1] == ']') { - host[strlen(host) - 1] = '\0'; - host++; - } -#else if (*host >= '0' && *host <= '9') { /* Test for numeric node address: */ strptr = host; while (*strptr) { @@ -1325,7 +1297,6 @@ PRIVATE int HTParseInet ARGS2( FREE(host); #endif /* _WINDOWS_NSL */ } else -#endif /* INET6 */ { /* Alphanumeric node name: */ #ifdef MVS /* Outstanding problem with crash in MVS gethostbyname */ @@ -1348,25 +1319,10 @@ PRIVATE int HTParseInet ARGS2( memcpy((void *)&soc_in->sin_addr, phost->h_addr, phost->h_length); #else /* !(__DJGPP__ && !WATT32) && !_WINDOWS_NSL */ { -#ifdef INET6 - struct addrinfo hints, *res; - int error; - - memset(&hints, 0, sizeof(hints)); - hints.ai_family = PF_UNSPEC; - error = getaddrinfo(host, port, &hints, &res); - - if (error || !res) { - CTRACE((tfp, "HTParseInet: getaddrinfo(%s): %s\n", host, - gai_strerror(error))); - goto failed; - } -#else struct hostent *phost; phost = LYGetHostByName(host); /* See above */ if (!phost) goto failed; -#endif /* INET6 */ #if defined(VMS) && defined(CMU_TCP) /* ** In LIBCMU, phost->h_length contains not the length of one address @@ -1376,32 +1332,14 @@ PRIVATE int HTParseInet ARGS2( ** longer supported, and CMU users are encouraged to obtain and use ** SOCKETSHR/NETLIB instead. - S. Bjorndahl */ -#ifdef INET6 - if (res->ai_family == AF_INET) { - memcpy((void *)&soc_in->sin_addr, - &((struct sockaddr_in *)res->ai_addr)->sin_addr, 4); - } else { - CTRACE(tfp, "HTParseInet: unsupported address family %d\n", - res->ai_family); - goto failed; - } -#else memcpy((void *)&soc_in->sin_addr, phost->h_addr, 4); -#endif /* INET6 */ -#else -#ifdef INET6 - memcpy((void *)soc_in, res->ai_addr, res->ai_addrlen); #else if (!phost) goto failed; if (phost->h_length != sizeof soc_in->sin_addr) { HTAlwaysAlert(host, gettext("Address length looks invalid")); } memcpy((void *)&soc_in->sin_addr, phost->h_addr, phost->h_length); -#endif /* INET6 */ #endif /* VMS && CMU_TCP */ -#ifdef INET6 - freeaddrinfo(res); -#endif /* INET6 */ } #endif /* _WINDOWS_NSL */ #endif /* __DJGPP__ && !WATT32 */ @@ -1411,14 +1349,12 @@ PRIVATE int HTParseInet ARGS2( } /* Alphanumeric node name */ -#ifndef INET6 CTRACE((tfp, "HTParseInet: Parsed address as port %d, IP address %d.%d.%d.%d\n", (int)ntohs(soc_in->sin_port), (int)*((unsigned char *)(&soc_in->sin_addr)+0), (int)*((unsigned char *)(&soc_in->sin_addr)+1), (int)*((unsigned char *)(&soc_in->sin_addr)+2), (int)*((unsigned char *)(&soc_in->sin_addr)+3))); -#endif /* !INET6 */ #endif /* Internet vs. Decnet */ return 0; /* OK */ @@ -1437,6 +1373,7 @@ failed: return -1; } } +#endif /* !INET6 */ #ifdef INET6 PRIVATE struct addrinfo * @@ -1475,7 +1412,7 @@ HTGetAddrInfo ARGS2( if (error || !res) { CTRACE((tfp, "HTGetAddrInfo: getaddrinfo(%s, %s): %s\n", host, port, gai_strerror(error))); - return NULL; + res = NULL; } return res; @@ -1765,7 +1702,7 @@ PUBLIC int HTDoConnect ARGS4( || SOCKET_ERRNO == EAGAIN #endif )) { - struct timeval timeout; + struct timeval select_timeout; int ret; int tries=0; @@ -1789,21 +1726,21 @@ PUBLIC int HTDoConnect ARGS4( } #ifdef _WINDOWS_NSL - timeout.tv_sec = connect_timeout; - timeout.tv_usec = 0; + select_timeout.tv_sec = connect_timeout; + select_timeout.tv_usec = 0; #else - timeout.tv_sec = 0; - timeout.tv_usec = 100000; + select_timeout.tv_sec = 0; + select_timeout.tv_usec = 100000; #endif /* _WINDOWS_NSL */ FD_ZERO(&writefds); FD_SET((unsigned) *s, &writefds); #ifdef SOCKS if (socks_flag) ret = Rselect(FD_SETSIZE, NULL, - (void *)&writefds, NULL, &timeout); + (void *)&writefds, NULL, &select_timeout); else #endif /* SOCKS */ - ret = select(FD_SETSIZE, NULL, (void *)&writefds, NULL, &timeout); + ret = select(FD_SETSIZE, NULL, (void *)&writefds, NULL, &select_timeout); #ifdef SOCKET_DEBUG_TRACE if (tries == 1) { @@ -1995,7 +1932,7 @@ PUBLIC int HTDoRead ARGS3( { int ready, ret; fd_set readfds; - struct timeval timeout; + struct timeval select_timeout; int tries=0; #ifdef EXP_READPROGRESS int otries = 0; @@ -2065,18 +2002,18 @@ PUBLIC int HTDoRead ARGS3( ** interrupted. Allow for this possibility. - JED */ do { - timeout.tv_sec = 0; - timeout.tv_usec = 100000; + select_timeout.tv_sec = 0; + select_timeout.tv_usec = 100000; FD_ZERO(&readfds); FD_SET((unsigned)fildes, &readfds); #ifdef SOCKS if (socks_flag) ret = Rselect(FD_SETSIZE, - (void *)&readfds, NULL, NULL, &timeout); + (void *)&readfds, NULL, NULL, &select_timeout); else #endif /* SOCKS */ ret = select(FD_SETSIZE, - (void *)&readfds, NULL, NULL, &timeout); + (void *)&readfds, NULL, NULL, &select_timeout); } while ((ret == -1) && (errno == EINTR)); if (ret < 0) { @@ -2166,17 +2103,17 @@ PUBLIC int BSDselect ARGS5( fd_set *, readfds, fd_set *, writefds, fd_set *, exceptfds, - struct timeval *, timeout) + struct timeval *, select_timeout) { int rval, i; #ifdef SOCKS if (socks_flag) - rval = Rselect(nfds, readfds, writefds, exceptfds, timeout); + rval = Rselect(nfds, readfds, writefds, exceptfds, select_timeout); else #endif /* SOCKS */ - rval = select(nfds, readfds, writefds, exceptfds, timeout); + rval = select(nfds, readfds, writefds, exceptfds, select_timeout); switch (rval) { case -1: diff --git a/WWW/Library/Implementation/HTTP.c b/WWW/Library/Implementation/HTTP.c index 6df60af4..51c57e9b 100644 --- a/WWW/Library/Implementation/HTTP.c +++ b/WWW/Library/Implementation/HTTP.c @@ -123,10 +123,10 @@ PUBLIC void HTSSLInitPRNG NOARGS RAND_seed((unsigned char *)&pid, sizeof(pid_t)); /* Initialize system's random number generator */ RAND_bytes((unsigned char *)&seed, sizeof(long)); - my_srand(seed); + lynx_srand(seed); while (RAND_status() == 0) { /* Repeatedly seed the PRNG using the system's random number generator until it has been seeded with enough data */ - l = my_rand(); + l = lynx_rand(); RAND_seed((unsigned char *)&l, sizeof(long)); } if (rand_file != NULL) { diff --git a/WWW/Library/Implementation/HTUtils.h b/WWW/Library/Implementation/HTUtils.h index ee787194..2017f36a 100644 --- a/WWW/Library/Implementation/HTUtils.h +++ b/WWW/Library/Implementation/HTUtils.h @@ -100,6 +100,14 @@ #define HAVE_UTMP 1 #endif +#ifndef lynx_srand +#define lynx_srand srand +#endif + +#ifndef lynx_rand +#define lynx_rand rand +#endif + #endif /* HAVE_CONFIG_H */ #if '0' != 48 diff --git a/WWW/Library/Implementation/SGML.c b/WWW/Library/Implementation/SGML.c index 430e36d0..be3bdc33 100644 --- a/WWW/Library/Implementation/SGML.c +++ b/WWW/Library/Implementation/SGML.c @@ -3651,7 +3651,7 @@ top1: if (string->data[1] == 'B' || string->data[1] == '@') { jis_buf[0] = '\033'; strcpy(jis_buf + 1, string->data); - TO_EUC(jis_buf, string->data); + TO_EUC((CONST unsigned char *)jis_buf, (unsigned char *)string->data); } } } diff --git a/WWW/Library/Implementation/makefile.in b/WWW/Library/Implementation/makefile.in index 96803c91..5d149785 100644 --- a/WWW/Library/Implementation/makefile.in +++ b/WWW/Library/Implementation/makefile.in @@ -171,6 +171,7 @@ $(LOB)/libwww.a : $(COMMON) # Clean up everything generatable except final products clean : + rm -f core *.core *.leaks *.[oi] *.bak tags TAGS rm $(LOB)/*.o # Common code |