ref: 52fc6d50d49b95e4598e2c9bb65e15e37035bf28
parent: 965bb2d2480363bf02ad0c10f92b7a6b4962e38f
author: cinap_lenrek <[email protected]>
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;
}