From be9f44a7dfb225f03b68ad9c94539528458c84ff Mon Sep 17 00:00:00 2001 From: Matt Kraai Date: Tue, 15 May 2001 03:05:39 +0000 Subject: [PATCH] Fix incorrect length passed to accept noted by Larry Doolittle. --- nc.c | 4 +++- networking/nc.c | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/nc.c b/nc.c index 72439dd85..b58bd6a12 100644 --- a/nc.c +++ b/nc.c @@ -80,10 +80,12 @@ 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); diff --git a/networking/nc.c b/networking/nc.c index 72439dd85..b58bd6a12 100644 --- a/networking/nc.c +++ b/networking/nc.c @@ -80,10 +80,12 @@ 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);