Re: [patch] Fix resource leak in netcat

2018-10-02 Thread Nan Xiao
Hi bluhm, Thanks very much for your reply! Yes, your patch covers all the corner cases, thanks! On 10/2/2018 8:38 AM, Alexander Bluhm wrote: > On Sun, Sep 30, 2018 at 11:55:58AM +0800, Nan Xiao wrote: >> The following patch fixed the resource leak when netcat works as a TLS >>

Re: [patch] Fix resource leak in netcat

2018-10-01 Thread Nan Xiao
Ping tech@, Any developer can comment on this patch? I think it is indeed a bug. Thanks! On 9/30/2018 11:55 AM, Nan Xiao wrote: > Hi tech@, > > The following patch fixed the resource leak when netcat works as a TLS > server. Sorry if I am wrong, thanks! > >

[patch] Fix resource leak in netcat

2018-09-29 Thread Nan Xiao
) { + tls_free(tls_ctx); + tls_ctx = NULL; + } } else if (family == AF_UNIX) { ret = 0; -- Best Regards Nan Xiao

Re: [patch]Modify the example code in write(2) manual

2018-09-26 Thread Nan Xiao
wrong, thanks very much in advance! On 9/26/2018 10:33 PM, Ingo Schwarze wrote: > Hi, > > Nan Xiao wrote on Wed, Sep 26, 2018 at 09:42:02PM +0800: > >> Any developer can comment on this patch? Thanks! > > I think this change is a bad idea and should not be committed

Re: [patch]Modify the example code in write(2) manual

2018-09-26 Thread Nan Xiao
ping tech@, Any developer can comment on this patch? Thanks! On 9/25/2018 10:10 PM, Nan Xiao wrote: > Hi tech@, > > I am reading write(2) manual, and come across the following example: > > for (off = 0; off < bsz; off += nw) > if ((nw = write(d, buf + off, bsz - o

[patch]Modify the example code in write(2) manual

2018-09-25 Thread Nan Xiao
-164,7 +164,7 @@ ssize_t nw; int d; for (off = 0; off < bsz; off += nw) - if ((nw = write(d, buf + off, bsz - off)) == 0 || nw == -1) + if ((nw = write(d, buf + off, bsz - off)) == -1) err(1, "write"); .Ed .Sh ERRORS Thanks! -- Best Regards Nan Xiao

Re: [patch] Add IPv6 description for `-T' option in netcat manual

2018-09-25 Thread Nan Xiao
Regards Nan Xiao On Tue, Sep 25, 2018 at 2:37 PM Jason McIntyre wrote: > > On Tue, Sep 25, 2018 at 09:11:42AM +0800, Nan Xiao wrote: > > Hi tech@, > > > > morning. > > > According to netcat source code, the `-T' option not only takes effect > > in IPv4 but a

[patch] Add IPv6 description for `-T' option in netcat manual

2018-09-24 Thread Nan Xiao
-269,7 +269,7 @@ for further details). Specifying TLS options requires .Fl c . .Pp -For the IPv4 TOS value, +For the IPv4 TOS/IPv6 Traffic Class value, .Ar keyword may be one of .Cm critical , Thanks! -- Best Regards Nan Xiao

Re: [patch] Fix "Address already in use" issue when using netcat with UNIX-domain socket

2018-09-21 Thread Nan Xiao
ping tech@, Very sorry for interrupting again! Anyone can give comment on this issue? Thanks! On 9/18/2018 6:37 PM, Nan Xiao wrote: > Hi tech@, > > Assume I use netcat with UNIX-domain socket, and there is no > temp_socket. Launch the server: > > # ./nc -U -l temp_socket >

Re: Maybe need to enrich `-T' option in netcat manual

2018-09-21 Thread Nan Xiao
*last_tos = inner_ip->ip_tos; } They indeed don't handle IPv6. But for netcat, it actually hangle IPv6 case at leaet from code in preceding mail. If netcat doesn't want to handle IPv6 intentionally, I think the IPv6 code should be removed, thanks! Best Regards Nan Xiao On Thu, Sep 20, 2018 at 7:45

Maybe need to enrich `-T' option in netcat manual

2018-09-19 Thread Nan Xiao
} So I think maybe the netcat manual should be enriched at least for `-T' option, thanks! -- Best Regards Nan Xiao

[patch] Fix "Address already in use" issue when using netcat with UNIX-domain socket

2018-09-18 Thread Nan Xiao
) return -1; } + if (lflag) + unlink(path); + if (bind(s, (struct sockaddr *)_un, sizeof(s_un)) < 0) { save_errno = errno; close(s); -- Best Regards Nan Xiao

[patch] Use the same backlog parameter for listen() function in netcat.c

2018-09-17 Thread Nan Xiao
(char *path) if ((s = unix_bind(path, 0)) < 0) return -1; - if (listen(s, 5) < 0) { + if (listen(s, 1) < 0) { close(s); return -1; } -- Best Regards Nan Xiao

[patch] Use correct data type in ldd.c

2018-09-14 Thread Nan Xiao
fd, i, status, interp=0; + size_t size; char buf[PATH_MAX]; struct stat st; void * dlhandle; -- Best Regards Nan Xiao

Re: [patch] Fix file descriptor leak in nohup.c

2018-09-14 Thread Nan Xiao
DOUT_FILENO) == -1) err(EXIT_MISC, NULL); + if (fd > STDERR_FILENO) + (void)close(fd); (void)fprintf(stderr, "sending output to %s\n", p); } On 9/12/2018 8:17 PM, Alexander Bluhm wrote: > On Sun, Sep 09, 2018 at 11:13:40AM +0800, Nan

Re: [patch] Fix an error in chmod.1

2018-09-14 Thread Nan Xiao
Hi Philip, Very sorry for my fault! Thanks very much for your time and explanation! On 9/14/2018 1:28 PM, Philip Guenther wrote: > On Thu, Sep 13, 2018 at 8:17 PM Nan Xiao <mailto:n...@chinadtrace.org>> wrote: > > The following patch fixes an error in chmod.1, and

[patch] Fix an error in chmod.1

2018-09-13 Thread Nan Xiao
represented by the specified .Ar who and -- Best Regards Nan Xiao

Re: [patch] Fix file descriptor leak in nohup.c

2018-09-08 Thread Nan Xiao
) || errno == EBADF) Since we close stderr, why do we need additional check of stdout here? Thanks in advacne! On 9/9/2018 7:39 AM, Alexander Bluhm wrote: > On Sat, Sep 08, 2018 at 08:47:28PM +0800, Nan Xiao wrote: >> I don't think need "if (fd > STDERR_FILENO)" cause the fd

Re: [patch] Fix file descriptor leak in nohup.c

2018-09-08 Thread Nan Xiao
exander Bluhm wrote: > On Sat, Sep 08, 2018 at 11:05:15AM +0800, Nan Xiao wrote: >> The following patch fixes file descriptor leak in `dofile' function. >> Sorry if I am wrong, thanks! > > It is a leak. > >> @@ -125,6 +125,7 @@ dupit: >> (void)l

[patch] Fix file descriptor leak in nohup.c

2018-09-07 Thread Nan Xiao
nding output to %s\n", p); } -- Best Regards Nan Xiao

[patch] Modify local_listen declaration in netcat.c

2018-09-07 Thread Nan Xiao
struct sock * address. Returns -1 on failure. */ int -local_listen(char *host, char *port, struct addrinfo hints) +local_listen(const char *host, const char *port, struct addrinfo hints) { struct addrinfo *res, *res0; int s = -1, ret, x = 1, save_errno; -- Best Regards Nan Xiao

Re: [patch] Fix closing socket twice bug in netcat program

2018-09-06 Thread Nan Xiao
close(connfd); >> } >> -if (family != AF_UNIX) >> -close(s); >> -else if (uflag) { >> +if (family == AF_UNIX && uflag) { >> if (connect(s, NULL, 0) < 0) >> err(1, "connect"); >> } > > otherwise OK bluhm@ > -- Best Regards Nan Xiao(肖楠)

Re: [patch] Fix closing socket twice bug in netcat program

2018-09-06 Thread Nan Xiao
8 5:07 AM, Alexander Bluhm wrote: > On Tue, Sep 04, 2018 at 01:01:38PM +0800, Nan Xiao wrote: >> Before netcat program exits, it will check whether s is -1, and close >> socket if s is not -1: >> >> if (s != -1) >> close(s); >> >> The follo

Re: [patch] Fix closing socket twice bug in netcat program

2018-09-05 Thread Nan Xiao
Ping tech@, Could anyone spare a minute to check this patch? I think it is indeed a bug. On 9/4/2018 1:01 PM, Nan Xiao wrote: > Hi tech@, > > Before netcat program exits, it will check whether s is -1, and close > socket if s is not -1: > > if (s != -1) >

[patch] Fix closing socket twice bug in netcat program

2018-09-03 Thread Nan Xiao
= -1; + } else if (uflag) { if (connect(s, NULL, 0) < 0) err(1, "connect"); } Thanks! -- Best Regards Nan Xiao

[patch] A small modification in /usr.bin/nc/netcat.c

2018-09-03 Thread Nan Xiao
int s = -1, ret, x = 1, save_errno; int error; - /* Allow nodename to be null. */ + /* Allow hostname to be null. */ hints.ai_flags |= AI_PASSIVE; /* -- Best Regards Nan Xiao

[patch] Use API to get params in lib/libtls/tls.c

2018-08-20 Thread Nan Xiao
PARAM_set_flags(X509_STORE_get0_param(store), X509_V_FLAG_CRL_CHECK | X509_V_FLAG_CRL_CHECK_ALL); } -- Best Regards Nan Xiao

Remove unused variable in usr.bin/openssl/apps.c

2018-08-16 Thread Nan Xiao
); - free_out = 1; } tree = X509_STORE_CTX_get0_policy_tree(ctx); explicit_policy = X509_STORE_CTX_get_explicit_policy(ctx); -- Best Regards Nan Xiao

[patch] consistent verb form in nc.1

2018-08-14 Thread Nan Xiao
n the peer certificate when using TLS. Illegal if not using TLS. .It Fl F Pass the first connected socket using -- Best Regards Nan Xiao

[patch] Add omitting period for ktrace(2) manual

2018-06-19 Thread Nan Xiao
-- Best Regards Nan Xiao

Re: [patch] Fix inaccurate comment in usr.bin/w/w.c

2018-06-15 Thread Nan Xiao
) && (hp = gethostbyaddr((char *), sizeof(addr), AF_INET))) { if (domain[0] != '\0') { p = hp->h_name; On 6/15/2018 5:57 AM, Raf Czlonka wrote: > On Thu, Jun 14, 2018 at 06:28:47AM BST, Nan Xiao wrot

[patch] Fix inaccurate comment in usr.bin/w/w.c

2018-06-13 Thread Nan Xiao
]; -- Best Regards Nan Xiao

Re: [patch] Use snprintf to implement concat in etc.c

2018-06-09 Thread Nan Xiao
Hi Philip, Thanks for your comments! On 6/9/2018 12:35 PM, Philip Guenther wrote: > On Thu, Jun 7, 2018 at 12:34 AM Nan Xiao <mailto:n...@chinadtrace.org>> wrote: > > I think maybe one snprintf is more efficient and concise. Sorry if I am > wrong, thanks! > &g

[patch] Use snprintf to implement concat in etc.c

2018-06-07 Thread Nan Xiao
= xmalloc(len); - strlcpy(str, s1, len); - strlcat(str, s2, len); - strlcat(str, s3, len); + snprintf(str, len, "%s%s%s", s1, s2, s3); return (str); } -- Best Regards Nan Xiao

[patch] Add error check for fchmod in ldconfig.c

2018-06-07 Thread Nan Xiao
%s", tmpfilenam); + goto out; + } if (write(fd, , sizeof(struct hints_header)) != sizeof(struct hints_header)) { -- Best Regards Nan Xiao

[patch] Remove unused variable in gnu/llvm/lib/Target/X86/X86FrameLowering.cpp

2018-06-06 Thread Nan Xiao
if (!MFI.hasReturnProtector() || !MFI.hasReturnProtectorTempRegister()) return; - unsigned CFIIndex; MachineBasicBlock::instr_iterator MBBI = MBB.instr_begin(); DebugLoc MBBDL = MBB.findDebugLoc(MBBI); const Function = MF.getFunction(); -- Best Regards Nan Xiao

Re: [patch] Add kvm_close in mib_hrsystemprocs function

2018-05-31 Thread Nan Xiao
Hi Gerhard, Thanks for your reply! Yes, if no "kvm_close(kd);", there will be resource (memory, file descriptor) leak. So hope you can commit it, thanks! On 5/30/2018 4:49 PM, Gerhard Roth wrote: > On Wed, 30 May 2018 16:25:55 +0800 Nan Xiao wrote: >> Hi tech@, >> >

[patch] Add kvm_close in mib_hrsystemprocs function

2018-05-30 Thread Nan Xiao
) + sizeof(struct kinfo_proc), ) == NULL) { + kvm_close(kd); return (-1); + } *elm = ber_add_integer(*elm, val); ber_set_header(*elm, BER_CLASS_APPLICATION, SNMP_T_GAUGE32); -- Best Regards Nan Xiao

Re: [patch] Reset sysload if sysctl call failed in usr.bin/top/machine.c

2018-05-24 Thread Nan Xiao
*infoloadp++ = ((double) sysload.ldavg[i]) / sysload.fscale; Thanks! On 5/24/2018 7:54 PM, Jeremie Courreges-Anglas wrote: > On Tue, May 22 2018, Nan Xiao <n...@chinadtrace.org> wrote: >> Hi tech@, >> >> Below is the patch of resetting sysload if sysctl call failed

[patch] Reset sysload if sysctl call failed in usr.bin/top/machine.c

2018-05-22 Thread Nan Xiao
ouble) sysload.ldavg[i]) / sysload.fscale; -- Best Regards Nan Xiao

[patch] Remove unnecessary timerclear in tcpbench

2018-05-11 Thread Nan Xiao
(); /* XXX Is there a better way to do this ? */ tv.tv_sec = ptb->rflag / 1000; tv.tv_usec = (ptb->rflag % 1000) * 1000; -- Best Regards Nan Xiao

[patch] Use err instead of errx for checking strdup failed

2018-05-10 Thread Nan Xiao
) - errx(1, "strdup"); + err(1, "strdup"); ptb->kvars = check_prepare_kvars(tmp); free(tmp); break; -- Best Regards Nan Xiao

Re: [patch] Set TCP send buffer size only when tcpbench client works in TCP mode

2018-05-10 Thread Nan Xiao
Very sorry for forgetting to cc reply into tech@. Forwarded Message Subject: Re: [patch] Set TCP send buffer size only when tcpbench client works in TCP mode Date: Thu, 10 May 2018 17:56:25 +0800 From: Nan Xiao <n...@chinadtrace.org> To: Alexander Bluhm <alexander.bl..

[patch] Set TCP send buffer size only when tcpbench client works in TCP mode

2018-05-10 Thread Nan Xiao
_MODE && ptb->Sflag) { if (setsockopt(sock, SOL_SOCKET, SO_SNDBUF, >Sflag, sizeof(ptb->Sflag)) == -1) warn("set TCP send buffer size"); -- Best Regards Nan Xiao

[patch] Unify format of tcpbench man page

2018-05-09 Thread Nan Xiao
the packets. .It Fl k Ar kvars Specify one or more kernel variables to monitor; multiple variables must be separated with commas. -- Best Regards Nan Xiao

[patch] Remove leading space in lib/libcrypto/asn1/a_time_tm.c

2018-05-07 Thread Nan Xiao
) + return (NULL); if (offset_day || offset_sec) { if (!OPENSSL_gmtime_adj(, offset_day, offset_sec)) -- Best Regards Nan Xiao

[patch] Exit directly when allocating memory failed in usr.bin/systat/cpu.c

2018-05-06 Thread Nan Xiao
(cpu_old[i] = calloc(CPUSTATES, sizeof(int64_t))) == NULL || (cpu_diff[i] = calloc(CPUSTATES, sizeof(int64_t))) == NULL) - return (-1); + err(2, NULL); } for (v = views_cpu; v->name != NULL; v++) -- Best Regards Nan Xiao

[patch] Test for sysctl call fail in usr.bin/systat/pigs.c

2018-05-03 Thread Nan Xiao
_mib, 2, , , NULL, 0) < 0) + return (-1); lccpu = log((double) ccpu / sysload.fscale); -- Best Regards Nan Xiao

[patch] Check memory allocation error in usr.bin/systat/vmstat.c

2018-05-03 Thread Nan Xiao
(i = 0; i < nintr; i++) { char name[128]; -- Best Regards Nan Xiao(肖楠)

Re: [patch] Add error handling in usr.bin/time/time.c

2018-04-20 Thread Nan Xiao
nd the above words from manual (https://man.openbsd.org/clock_gettime.2). Anyway, thanks for pointing it out! On 4/20/2018 8:00 PM, Ingo Schwarze wrote: > Hi, > > Nan Xiao wrote on Fri, Apr 20, 2018 at 05:28:01PM +0800: > >> FYI, thanks! > > No. Read the manual page and

Re: [patch] Remove redundant quotes in sys/sys/resource.h and sys/sys/sysctl.h

2018-04-20 Thread Nan Xiao
Hi Theo, I am very sorry for this wrong modification! Thanks! Best Regards Nan Xiao On Fri, Apr 20, 2018 at 4:57 PM, Theo Buehler <t...@openbsd.org> wrote: > I don't think these are "redundant quotes" but rather ditto marks: > > https://en.wikipedia.org/wiki/Ditto_mar

[patch] Add error handling in usr.bin/time/time.c

2018-04-20 Thread Nan Xiao
err(1, "clock_gettime"); if (WIFSIGNALED(status)) exitonsig = WTERMSIG(status); if (!WIFEXITED(status)) -- Best Regards Nan Xiao

[patch] Remove redundant quotes in sys/sys/resource.h and sys/sys/sysctl.h

2018-04-20 Thread Nan Xiao
/* LONG: involuntary ". */ + u_int64_t p_uru_nivcsw; /* LONG: involuntary. */ u_int32_t p_uctime_sec; /* STRUCT TIMEVAL: child u+s time. */ u_int32_t p_uctime_usec;/* STRUCT TIMEVAL: child u+s time. */ -- Best Regards Nan Xiao

[patch] Chane wfd to static variable in cat.c

2018-04-11 Thread Nan Xiao
static size_t bsize; static char *buf = NULL; struct stat sbuf; - wfd = fileno(stdout); if (buf == NULL) { + wfd = fileno(stdout); if (fstat(wfd, )) err(1, "stdout"); bsize = MAXIMUM(sbuf.st_blksize,

The doubt about "link-layer header type" for loopback packet

2017-11-19 Thread Nan Xiao
erning about the "link-layer header type" of loopback packet, is it reasonable to use "0x6C" instead of "0x0C"? Thanks very much in advance! Best Regards Nan Xiao

Re: [patch]Use BUFSIZE instead of hard-code in netcat.c

2017-10-24 Thread Nan Xiao
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 <xiaonan830...@gmail.com> wrote: > Actually, I think "plen = sizeof(buf);" may be better. > B

Re: [patch]Use BUFSIZE instead of hard-code in netcat.c

2017-10-24 Thread Nan Xiao
Actually, I think "plen = sizeof(buf);" may be better. Best Regards Nan Xiao On Tue, Oct 24, 2017 at 8:52 PM, Alexander Bluhm <alexander.bl...@gmx.net> wrote: > On Tue, Oct 24, 2017 at 07:44:02PM +0800, Nan Xiao wrote: >> Use BUFSIZE instead of hard-code

[patch]Use BUFSIZE instead of hard-code in netcat.c

2017-10-24 Thread Nan Xiao
Hi tech@, Use BUFSIZE instead of hard-code in netcat.c, FYI. Thanks! Best Regards Nan Xiao Index: netcat.c === RCS file: /cvs/src/usr.bin/nc/netcat.c,v retrieving revision 1.187 diff -u -p -r1.187 netcat.c --- netcat.c15 Jul

[patch] Fix wrong warn message in ldd.c

2017-10-04 Thread Nan Xiao
Hi tech@, The following check can only know whether the file is ELF or not, can't know whether it is shared object or executable. So I think the error message should be more accurate. Thanks! Best Regards Nan Xiao Index: ldd.c

Why the executable file type is also "DYN", not "EXEC"?

2017-10-04 Thread Nan Xiao
ement, little endian Version: 1 (current) OS/ABI:UNIX - System V ABI Version: 0 Type: DYN (Shared object file) .. Is there any special consideration for it? Thanks very much in advanc

[patch] Modify checking read ELF header file condition in ldd.c

2017-10-03 Thread Nan Xiao
Hi tech@, I think check the actual read ELF header file size is better than just "<0", thanks! Best Reagrds Nan Xiao Index: ldd.c === RCS file: /cvs/src/libexec/ld.so/ldd/ldd.c,v retrieving revision 1.21 diff -u -p

[patch] Change size's type from int to size_t in ldd.c

2017-09-27 Thread Nan Xiao
Hi tech@, I think the type of size variable should be more accurate to use size_t instead of int. Best Regards Nan Xiao Index: ldd.c === RCS file: /cvs/src/libexec/ld.so/ldd/ldd.c,v retrieving revision 1.21 diff -u -p -r1.21 ldd.c

[patch] Close file descriptor before exiting ldd

2017-09-26 Thread Nan Xiao
Hi tech@, FYI, thanks! Best Regards Nan Xiao Index: ldd.c === RCS file: /cvs/src/libexec/ld.so/ldd/ldd.c,v retrieving revision 1.21 diff -u -p -r1.21 ldd.c --- ldd.c 2 Jul 2017 19:06:12 - 1.21 +++ ldd.c 27 Sep

[Patch] Remove unnecessary assignment in pctr.c

2017-09-10 Thread Nan Xiao
Hi tech@ Remove unnecessary assignment. Thanks! Best Regards Nan Xiao Index: pctr.c === RCS file: /cvs/src/usr.bin/pctr/pctr.c,v retrieving revision 1.23 diff -u -p -r1.23 pctr.c --- pctr.c 10 Sep 2017 11:30:43 - 1.23

Re: [patch] Remove redundant operation in pctr.c

2017-09-09 Thread Nan Xiao
Actually, it should be more efficient to remove bzero() function and keep set NULL-terminate char. Best Regards Nan Xiao Index: pctr.c === RCS file: /cvs/src/usr.bin/pctr/pctr.c,v retrieving revision 1.22 diff -u -p -r1.22 pctr.c

Re: [patch] Initialize "cur" to avoid undefined behavior is dmesg.c

2017-09-04 Thread Nan Xiao
Hi Tom, Updated, thanks! Best Regards Nan Xiao Index: dmesg.c === RCS file: /cvs/src/sbin/dmesg/dmesg.c,v retrieving revision 1.29 diff -u -p -r1.29 dmesg.c --- dmesg.c 1 Sep 2017 07:31:45 - 1.29 +++ dmesg.c 4 Sep

[patch] Initialize "cur" to avoid undefined behavior is dmesg.c

2017-09-04 Thread Nan Xiao
< cur.msg_bufs; i++, p++) { . } My patch can skip the whole loop, and the "dmesg" program just prints a newline: if (!newl) putchar('\n'); Best Regards Nan Xiao Index: dmesg.c === RCS file: /cvs

Is it possible for "NOKVM" defined in reality?

2017-09-02 Thread Nan Xiao
be NULL. Hope to check it, thanks! Best Regards Nan Xiao

[patch] Fix memory leak in dmeg.c

2017-08-31 Thread Nan Xiao
Hi tech@, I am not a nitpicker. Though all memory will be reclaimed after process exits, I still think it's a good habit to release all memory in heap. Best Regards Nan Xiao Index: dmesg.c === RCS file: /cvs/src/sbin/dmesg/dmesg.c