git: 9front

Download patch

ref: 1168cce1e38d12939279ba45dfd6853edd29f0d2
parent: a72384809a9705a56c7608bb18f514f7f06a1a7a
author: cinap_lenrek <cinap_lenrek@gmx.de>
date: Wed Oct 16 12:42:40 EDT 2013

nusb/ether: fix wrong size check causing odd sized packets to be discarded (thanks mischief!)

ethernet packets with sizes that where not multiples of 4 where
discarded because the check uses the smsc frame size instead of
the payload size. when a usb read returns just one packet, theres
no next frame header and the calculated frame size is bigger than
the usb read which caused the whole packet to be discarded as invalid.

thanks to mischief for testing and debugging!

--- a/sys/src/cmd/nusb/ether/smsc.c
+++ b/sys/src/cmd/nusb/ether/smsc.c
@@ -219,7 +219,7 @@
 	hd = GET4(bin);
 	n = hd >> 16;
 	m = (n + 4 + 3) & ~3;
-	if(n < 6 || m > nbin){
+	if(n < 6 || n > nbin-4){
 		nbin = 0;
 		return 0;
 	}
--