resist crashing when given esp connections. example minooka# cat /net/esp/1/local :: note lack of !port minooka# cat /net/esp/1/status Closed strrchr(.., ' ') will fail on this string and \n messes up output. - erik Reference: /n/sources/patch/applied/netstatesp Date: Tue Apr 13 20:33:34 CES 2010 Signed-off-by: quanstro@quanstro.net --- /sys/src/cmd/netstat.c Tue Apr 13 20:31:26 2010 +++ /sys/src/cmd/netstat.c Tue Apr 13 20:31:23 2010 @@ -147,7 +147,9 @@ p = strchr(buf, ' '); if(p != 0) *p = 0; - + p = strrchr(buf, '\n'); + if(p != 0) + *p = 0; Bprint(&out, "%-4s %-4s %-10s %-12s ", net, db->name, db->uid, buf); sprint(buf, "%s/%s/%s/local", netroot, net, db->name); @@ -185,7 +187,8 @@ buf[n-1] = 0; close(fd); p = strchr(buf, '!'); - *p++ = '\0'; + if(p != nil) + *p++ = '\0'; if(notrans){ Bprint(&out, "%-10s %s\n", getport(net, p), buf);