shithub: riscv

Download patch

ref: 099da8cb824ee60bf3f55e9e69380660f167b216
parent: 22b28520cd431c2f68acd66b877122379d704914
author: cinap_lenrek <[email protected]>
date: Wed Nov 28 07:41:18 EST 2018

devip: fix arpread, dont return partial entries

--- a/sys/src/9/ip/arp.c
+++ b/sys/src/9/ip/arp.c
@@ -460,16 +460,17 @@
 		qunlock(arp);
 		runlock(ifc);
 
-		n = snprint(p, len, "%-6.6s %-4.4s %-40.40I %-16.16s %I\n",
+		n = snprint(up->genbuf, sizeof up->genbuf,
+			"%-6.6s %-4.4s %-40.40I %-16.16s %I\n",
 			mname, state, ip, mac, ia);
-		if(o < 0) {
-			if(n > -o)
-				memmove(p, p-o, n+o);
-			o += n;
-		} else {
-			len -= n;
-			p += n;
-		}
+		o += n;
+		if(o <= 0)
+			continue;
+		if(n > len)
+			break;
+		memmove(p, up->genbuf, n);
+		len -= n;
+		p += n;
 	}
 
 	return p - s;