diff options
author | Conrad Pankoff <deoxxa@fknsrs.biz> | 2019-08-10 13:50:58 +1000 |
---|---|---|
committer | Andreas Kling <awesomekling@gmail.com> | 2019-08-10 08:51:20 +0200 |
commit | e978e7543fd0af968c2b734da09589480caeeca5 (patch) | |
tree | c7d2ce8e2aea17926cb616c0947741cd2212dce1 /Userland | |
parent | 5308e310a0dae93b7ba7d0082355caba80d3d9bb (diff) | |
download | serenity-e978e7543fd0af968c2b734da09589480caeeca5.zip |
Userland: Make sure sockaddr_len is initialised correctly in nc
Diffstat (limited to 'Userland')
-rw-r--r-- | Userland/nc.cpp | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/Userland/nc.cpp b/Userland/nc.cpp index e097be0039..da9e0730c7 100644 --- a/Userland/nc.cpp +++ b/Userland/nc.cpp @@ -85,8 +85,9 @@ int main(int argc, char** argv) char addr_str[100]; struct sockaddr_in sin; - socklen_t len = sizeof(sin); + socklen_t len; + len = sizeof(sin); if (getsockname(listen_fd, (struct sockaddr*)&sin, &len) == -1) { perror("getsockname"); return 1; @@ -94,6 +95,7 @@ int main(int argc, char** argv) if (verbose) fprintf(stderr, "waiting for a connection on %s:%d\n", inet_ntop(sin.sin_family, &sin.sin_addr, addr_str, sizeof(addr_str) - 1), ntohs(sin.sin_port)); + len = sizeof(sin); fd = accept(listen_fd, (struct sockaddr*)&sin, &len); if (fd == -1) { perror("accept"); |