diff options
Diffstat (limited to '')
-rw-r--r-- | ChangeLog | 8 | ||||
-rw-r--r-- | src/sock.c | 4 |
2 files changed, 11 insertions, 1 deletions
@@ -1,3 +1,11 @@ +2001-10-22 Robert James Kaes <rjkaes@flarenet.com> + + * src/sock.c (getpeer_string): + * src/sock.c (getpeer_ip): When the DNS lookup fails, we need to + initialized the user's buffer to an empty string; otherwise, the + user's buffer will contain garbage and cause a SEGFAULT. Thanks to + Jeffrey Wheelhouse for finding this bug. + 2001-10-18 Robert James Kaes <rjkaes@flarenet.com> * src/reqs.c (connect_to_upstream): Moved the code needed to @@ -1,4 +1,4 @@ -/* $Id: sock.c,v 1.8 2001-09-16 20:11:07 rjkaes Exp $ +/* $Id: sock.c,v 1.9 2001-10-22 15:56:11 rjkaes Exp $ * * Sockets are created and destroyed here. When a new connection comes in from * a client, we need to copy the socket and the create a second socket to the @@ -162,6 +162,7 @@ char *getpeer_ip(int fd, char *ipaddr) if (getpeername(fd, (struct sockaddr*)&name, &namelen) != 0) { log_message(LOG_ERR, "Connect: 'could not get peer name'"); + *ipaddr = '\0'; } else { strlcpy(ipaddr, inet_ntoa(*(struct in_addr*)&name.sin_addr.s_addr), @@ -186,6 +187,7 @@ char *getpeer_string(int fd, char *string) if (getpeername(fd, (struct sockaddr *)&name, &namelen) != 0) { log_message(LOG_ERR, "Connect: 'could not get peer name'"); + *string = '\0'; } else { LOCK(); peername = gethostbyaddr((char *)&name.sin_addr.s_addr, |