aboutsummaryrefslogtreecommitdiff
path: root/networking
diff options
context:
space:
mode:
Diffstat (limited to 'networking')
-rw-r--r--networking/dnsd.c5
-rw-r--r--networking/fakeidentd.c4
-rw-r--r--networking/httpd.c9
-rw-r--r--networking/nc.c7
-rw-r--r--networking/telnetd.c10
-rw-r--r--networking/traceroute.c4
6 files changed, 12 insertions, 27 deletions
diff --git a/networking/dnsd.c b/networking/dnsd.c
index d78ea04c0..b9d022170 100644
--- a/networking/dnsd.c
+++ b/networking/dnsd.c
@@ -216,9 +216,8 @@ listen_socket(char *iface_addr, int listen_port)
a.sin_family = AF_INET;
if (!inet_aton(iface_addr, &a.sin_addr))
bb_perror_msg_and_die("bad iface address");
- if (bind(s, (struct sockaddr *)&a, sizeof(a)) < 0)
- bb_perror_msg_and_die("bind() failed");
- listen(s, 50);
+ bb_xbind(s, (struct sockaddr *)&a, sizeof(a));
+ listen(s, 50); /* bb_xlisten? */
sprintf(msg, "accepting UDP packets on addr:port %s:%d\n",
iface_addr, (int)listen_port);
log_message(LOG_FILE, msg);
diff --git a/networking/fakeidentd.c b/networking/fakeidentd.c
index 26efdcb34..cae6b8138 100644
--- a/networking/fakeidentd.c
+++ b/networking/fakeidentd.c
@@ -113,10 +113,10 @@ static void inetbind(void)
addr.sin_family = AF_INET;
addr.sin_port = htons(port);
- if (bind(s, (struct sockaddr *)&addr, len) < 0)
+ if (bind(s, (struct sockaddr *)&addr, len) < 0) /* bb_xbind? */
bb_perror_msg_and_die("Cannot bind() port %i", IDENT_PORT);
- if (listen(s, 5) < 0)
+ if (listen(s, 5) < 0) /* bb_xlisten? */
bb_perror_msg_and_die("Cannot listen() on port %i", IDENT_PORT);
movefd(s, 0);
diff --git a/networking/httpd.c b/networking/httpd.c
index 354c199e7..0f6174140 100644
--- a/networking/httpd.c
+++ b/networking/httpd.c
@@ -958,12 +958,9 @@ static int openServer(void)
#else
setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, (void *)&on, sizeof(on)) ;
#endif
- if (bind(fd, (struct sockaddr *)&lsocket, sizeof(lsocket)) == 0) {
- listen(fd, 9);
- signal(SIGCHLD, SIG_IGN); /* prevent zombie (defunct) processes */
- } else {
- bb_perror_msg_and_die("bind");
- }
+ bb_xbind(fd, (struct sockaddr *)&lsocket, sizeof(lsocket));
+ listen(fd, 9); /* bb_xlisten? */
+ signal(SIGCHLD, SIG_IGN); /* prevent zombie (defunct) processes */
return fd;
}
#endif /* CONFIG_FEATURE_HTTPD_USAGE_FROM_INETD_ONLY */
diff --git a/networking/nc.c b/networking/nc.c
index 86f0b99df..57b091744 100644
--- a/networking/nc.c
+++ b/networking/nc.c
@@ -90,16 +90,13 @@ int nc_main(int argc, char **argv)
memset(&address.sin_addr, 0, sizeof(address.sin_addr));
address.sin_port = lport;
- if (bind(sfd, (struct sockaddr *) &address, sizeof(address)) < 0)
- bb_perror_msg_and_die("bind");
+ bb_xbind(sfd, (struct sockaddr *) &address, sizeof(address));
}
if (do_listen) {
socklen_t addrlen = sizeof(address);
- if (listen(sfd, 1) < 0)
- bb_perror_msg_and_die("listen");
-
+ bb_xlisten(sfd, 1);
if ((tmpfd = accept(sfd, (struct sockaddr *) &address, &addrlen)) < 0)
bb_perror_msg_and_die("accept");
diff --git a/networking/telnetd.c b/networking/telnetd.c
index d53f56b14..1a53c0c0c 100644
--- a/networking/telnetd.c
+++ b/networking/telnetd.c
@@ -461,14 +461,8 @@ telnetd_main(int argc, char **argv)
sa.sin_addr = bind_addr;
#endif
- if (bind(master_fd, (struct sockaddr *) &sa, sizeof(sa)) < 0) {
- bb_perror_msg_and_die("bind");
- }
-
- if (listen(master_fd, 1) < 0) {
- bb_perror_msg_and_die("listen");
- }
-
+ bb_xbind(master_fd, (struct sockaddr *) &sa, sizeof(sa));
+ bb_xlisten(master_fd, 1);
bb_xdaemon(0, 0);
maxfd = master_fd;
diff --git a/networking/traceroute.c b/networking/traceroute.c
index 0abd9047d..4f7ebf176 100644
--- a/networking/traceroute.c
+++ b/networking/traceroute.c
@@ -1253,9 +1253,7 @@ traceroute_main(int argc, char *argv[])
outip->ip_src = from->sin_addr;
#ifndef IP_HDRINCL
- if (bind(sndsock, (struct sockaddr *)from, sizeof(*from)) < 0) {
- bb_perror_msg_and_die("bind");
- }
+ bb_xbind(sndsock, (struct sockaddr *)from, sizeof(*from));
#endif
fprintf(stderr, "traceroute to %s (%s)", hostname, inet_ntoa(to->sin_addr));