summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorRobert James Kaes <rjkaes@users.sourceforge.net>2002-04-13 19:03:18 +0000
committerRobert James Kaes <rjkaes@users.sourceforge.net>2002-04-13 19:03:18 +0000
commitc86d22226ff952b33cf4fbee23f0172b86230024 (patch)
tree870703936553ad4277d8ceced86367c480beb6ea /src
parent6c2d7ebaa4b1c7cba0ce2c47b633666337b2f9b8 (diff)
downloadtinyproxy-c86d22226ff952b33cf4fbee23f0172b86230024.tar.gz
tinyproxy-c86d22226ff952b33cf4fbee23f0172b86230024.zip
Added additional error handling for the bind() and listen() system calls
when setting up the listening socket.
Diffstat (limited to 'src')
-rw-r--r--src/sock.c14
1 files changed, 11 insertions, 3 deletions
diff --git a/src/sock.c b/src/sock.c
index 7f76336..004d0b6 100644
--- a/src/sock.c
+++ b/src/sock.c
@@ -1,4 +1,4 @@
-/* $Id: sock.c,v 1.24 2002-04-13 05:20:19 rjkaes Exp $
+/* $Id: sock.c,v 1.25 2002-04-13 19:03:18 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
@@ -206,9 +206,17 @@ listen_sock(uint16_t port, socklen_t * addrlen)
addr.sin_addr.s_addr = inet_addr("0.0.0.0");
}
- bind(listenfd, (struct sockaddr *) &addr, sizeof(addr));
+ if (bind(listenfd, (struct sockaddr *) &addr, sizeof(addr)) < 0) {
+ log_message(LOG_ERR, "Unable to bind listening socket because of %s",
+ strerror(errno));
+ return -1;
+ }
- listen(listenfd, MAXLISTEN);
+ if (listen(listenfd, MAXLISTEN) < 0) {
+ log_message(LOG_ERR, "Unable to start listening socket because of %s",
+ strerror(errno));
+ return -1;
+ }
*addrlen = sizeof(addr);