Ouch! I misunderstood the patch by @bluhm, please ignore my previous mail! I am very sorry for disrupting! Best Regards Nan Xiao
On Tue, Oct 24, 2017 at 9:30 PM, Nan Xiao <[email protected]> wrote: > Actually, I think "plen = sizeof(buf);" may be better. > Best Regards > Nan Xiao > > > On Tue, Oct 24, 2017 at 8:52 PM, Alexander Bluhm > <[email protected]> wrote: >> On Tue, Oct 24, 2017 at 07:44:02PM +0800, Nan Xiao wrote: >>> Use BUFSIZE instead of hard-code in netcat.c, FYI. Thanks! >> >> As this buffer is used with MSG_PEEK and its content is discarded, >> the size does not really matter. The complicated logic seems to >> be a leftover from the -j jumbo option. >> >> I think this is simpler. >> >> bluhm >> >> Index: usr.bin/nc/netcat.c >> =================================================================== >> RCS file: /data/mirror/openbsd/cvs/src/usr.bin/nc/netcat.c,v >> retrieving revision 1.187 >> diff -u -p -r1.187 netcat.c >> --- usr.bin/nc/netcat.c 15 Jul 2017 17:27:39 -0000 1.187 >> +++ usr.bin/nc/netcat.c 24 Oct 2017 12:41:38 -0000 >> @@ -563,13 +563,12 @@ main(int argc, char *argv[]) >> * initially to wait for a caller, then use >> * the regular functions to talk to the >> caller. >> */ >> - int rv, plen; >> - char buf[16384]; >> + int rv; >> + char buf[2048]; >> struct sockaddr_storage z; >> >> len = sizeof(z); >> - plen = 2048; >> - rv = recvfrom(s, buf, plen, MSG_PEEK, >> + rv = recvfrom(s, buf, sizeof(buf), MSG_PEEK, >> (struct sockaddr *)&z, &len); >> if (rv < 0) >> err(1, "recvfrom");
