Fix a merge problem in which name_from_addr returned pointers to the stack; found by Jiang Hong.

svn:r934
This commit is contained in:
Niels Provos 2008-09-04 01:09:54 +00:00
parent 1fc7059cbe
commit d2386bce75
2 changed files with 9 additions and 2 deletions

View File

@ -1,5 +1,6 @@
Changes in 1.4.8-stable:
o Match the query in DNS replies to the query in the request; from Vsevolod Stakhov.
o Fix a merge problem in which name_from_addr returned pointers to the stack; found by Jiang Hong.
Changes in 1.4.7-stable:
o Fix a bug where headers arriving in multiple packets were not parsed; fix from Jiang Hong; test by me.

10
http.c
View File

@ -2488,6 +2488,12 @@ evhttp_get_request_connection(
char *hostname = NULL, *portname = NULL;
name_from_addr(sa, salen, &hostname, &portname);
if (hostname == NULL || portname == NULL) {
if (hostname) free(hostname);
if (portname) free(portname);
return (NULL);
}
event_debug(("%s: new request from %s:%s on %d\n",
__func__, hostname, portname, fd));
@ -2614,8 +2620,8 @@ name_from_addr(struct sockaddr *sa, socklen_t salen,
if (ni_result != 0)
return;
#endif
*phost = ntop;
*pport = strport;
*phost = strdup(ntop);
*pport = strdup(strport);
}
/* Either connect or bind */