summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorRobert James Kaes <rjkaes@users.sourceforge.net>2001-10-22 15:56:11 +0000
committerRobert James Kaes <rjkaes@users.sourceforge.net>2001-10-22 15:56:11 +0000
commitad743c1e41635a903aed50935afcb411f8388408 (patch)
tree44b444136690abad33ddd088b2c51e3d8a53636c /src
parentb40e382e5a40ce8ccf980d693e92a38e3d32b75b (diff)
downloadtinyproxy-ad743c1e41635a903aed50935afcb411f8388408.tar.gz
tinyproxy-ad743c1e41635a903aed50935afcb411f8388408.zip
Fixed a problem where a user's variable would be uninitialized if a DNS
lookup failed.
Diffstat (limited to 'src')
-rw-r--r--src/sock.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/sock.c b/src/sock.c
index 46e5170..6e5f839 100644
--- a/src/sock.c
+++ b/src/sock.c
@@ -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,