dgaudet 97/07/31 00:51:36
Modified: src http_core.c Log: Fix a null deref, and improper status update in the double reverse code. Revision Changes Path 1.103 +30 -16 apache/src/http_core.c Index: http_core.c =================================================================== RCS file: /export/home/cvs/apache/src/http_core.c,v retrieving revision 1.102 retrieving revision 1.103 diff -u -r1.102 -r1.103 --- http_core.c 1997/07/30 18:41:51 1.102 +++ http_core.c 1997/07/31 07:51:34 1.103 @@ -335,6 +335,11 @@ /* already done */ return; } + if (conn->remote_host == NULL || conn->remote_host[0] == '\0') { + /* single reverse failed, so don't bother */ + conn->double_reverse = -1; + return; + } hptr = gethostbyname(conn->remote_host); if (hptr) { for (haddr = hptr->h_addr_list; *haddr; haddr++) { @@ -355,20 +360,28 @@ { struct in_addr *iaddr; struct hostent *hptr; - core_dir_config *dir_conf = NULL; + int hostname_lookups; +#ifdef STATUS + int old_stat = SERVER_UNKNOWN; +#endif -/* If we haven't checked the host name, and we want to */ - if (dir_config) - dir_conf = (core_dir_config *)get_module_config(dir_config, &core_module); + /* If we haven't checked the host name, and we want to */ + if (dir_config) { + hostname_lookups = + ((core_dir_config *)get_module_config(dir_config, &core_module)) + ->hostname_lookups; + } else { + /* the default */ + hostname_lookups = HOSTNAME_LOOKUP_OFF; + } - if ((!dir_conf) || (type != REMOTE_NOLOOKUP && conn->remote_host == NULL + if (type != REMOTE_NOLOOKUP + && conn->remote_host == NULL && (type == REMOTE_DOUBLE_REV - || dir_conf->hostname_lookups != HOSTNAME_LOOKUP_OFF))) - { + || hostname_lookups != HOSTNAME_LOOKUP_OFF)) { #ifdef STATUS - int old_stat = update_child_status(conn->child_num, - SERVER_BUSY_DNS, - (request_rec*)NULL); + old_stat = update_child_status(conn->child_num, SERVER_BUSY_DNS, + (request_rec*)NULL); #endif /* STATUS */ iaddr = &(conn->remote_addr.sin_addr); hptr = gethostbyaddr((char *)iaddr, sizeof(struct in_addr), AF_INET); @@ -376,19 +389,15 @@ conn->remote_host = pstrdup(conn->pool, (void *)hptr->h_name); str_tolower (conn->remote_host); - if (dir_conf - && dir_conf->hostname_lookups == HOSTNAME_LOOKUP_DOUBLE) { + if (hostname_lookups == HOSTNAME_LOOKUP_DOUBLE) { do_double_reverse (conn); if (conn->double_reverse != 1) { conn->remote_host = NULL; } } } -/* if failed, set it to the NULL string to indicate error */ + /* if failed, set it to the NULL string to indicate error */ if (conn->remote_host == NULL) conn->remote_host = ""; -#ifdef STATUS - (void)update_child_status(conn->child_num,old_stat,(request_rec*)NULL); -#endif /* STATUS */ } if (type == REMOTE_DOUBLE_REV) { do_double_reverse (conn); @@ -396,6 +405,11 @@ return NULL; } } +#ifdef STATUS + if (old_stat != SERVER_UNKNOWN) { + (void)update_child_status(conn->child_num,old_stat,(request_rec*)NULL); + } +#endif /* STATUS */ /* * Return the desired information; either the remote DNS name, if found,