On Sun, Jan 05, 2020 at 06:41:08PM +0100, Alexander Bluhm wrote: > Hi, > > When using netcat with the options -Uuvs I get: > > netcat-regress: getnameinfo: Invalid argument > > Using the same check when calling report_sock() as a few lines below > fixes it. > > While there use the same error check for both calls to getnameinfo(3). > > ok?
ok tb Note that there was a related bug report (including a diff) in August that was ignored: https://marc.info/?l=openbsd-bugs&m=156551644519192&w=2 (point 2 refers to the problem you're addressing here). > > bluhm > > Index: usr.bin/nc/netcat.c > =================================================================== > RCS file: /data/mirror/openbsd/cvs/src/usr.bin/nc/netcat.c,v > retrieving revision 1.212 > diff -u -p -r1.212 netcat.c > --- usr.bin/nc/netcat.c 17 Nov 2019 17:38:33 -0000 1.212 > +++ usr.bin/nc/netcat.c 5 Jan 2020 17:26:07 -0000 > @@ -597,7 +597,8 @@ main(int argc, char *argv[]) > > if (vflag) > report_sock("Connection received", > - (struct sockaddr *)&z, len, NULL); > + (struct sockaddr *)&z, len, > + family == AF_UNIX ? host : NULL); > > readwrite(s, NULL); > } else { > @@ -1784,11 +1785,14 @@ report_sock(const char *msg, const struc > if (nflag) > flags |= NI_NUMERICHOST; > > - if ((herr = getnameinfo(sa, salen, host, sizeof(host), > - port, sizeof(port), flags)) != 0) { > - if (herr == EAI_SYSTEM) > + herr = getnameinfo(sa, salen, host, sizeof(host), port, sizeof(port), > + flags); > + switch (herr) { > + case 0: > + break; > + case EAI_SYSTEM: > err(1, "getnameinfo"); > - else > + default: > errx(1, "getnameinfo: %s", gai_strerror(herr)); > } >
