Fix incorrect length passed to accept noted by Larry Doolittle.

This commit is contained in:
Matt Kraai 2001-05-15 03:05:39 +00:00
parent 336480fe6f
commit be9f44a7df
2 changed files with 6 additions and 2 deletions

4
nc.c
View File

@ -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);

View File

@ -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);