This depmod script will create a modules.dep file, just like the depmod
[oweals/busybox.git] / nc.c
diff --git a/nc.c b/nc.c
index e40d4b459491fd307b6b456f14dcb05d44926509..5335872e5a7ca50b4e3fa5b410fbffb333d459b9 100644 (file)
--- a/nc.c
+++ b/nc.c
@@ -28,6 +28,7 @@
 
 #include <stdio.h>
 #include <stdlib.h>
+#include <string.h>
 #include <unistd.h>
 
 #include <sys/types.h>
@@ -79,17 +80,18 @@ int nc_main(int argc, char **argv)
        }
 
        if (do_listen) {
+               socklen_t addrlen = sizeof(address);
+
                if (listen(sfd, 1) < 0)
                        perror_msg_and_die("listen");
 
-               if ((tmpfd = accept(sfd, (struct sockaddr *) &address, &opt)) < 0)
+               if ((tmpfd = accept(sfd, (struct sockaddr *) &address, &addrlen)) < 0)
                        perror_msg_and_die("accept");
 
                close(sfd);
                sfd = tmpfd;
        } else {
-               if ((hostinfo = gethostbyname(argv[optind])) == NULL)
-                       error_msg_and_die("cannot resolve %s\n", argv[optind]);
+               hostinfo = xgethostbyname(argv[optind]);
 
                address.sin_addr = *(struct in_addr *) *hostinfo->h_addr_list;
                address.sin_port = htons(atoi(argv[optind+1]));