summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcinap_lenrek <cinap_lenrek@gmx.de>2013-10-16 16:42:40 +0200
committercinap_lenrek <cinap_lenrek@gmx.de>2013-10-16 16:42:40 +0200
commit52fc6d50d49b95e4598e2c9bb65e15e37035bf28 (patch)
treea0a812ce48085b0cdefa1de6180ba25a43d8fa5b
parent965bb2d2480363bf02ad0c10f92b7a6b4962e38f (diff)
downloadplan9front-52fc6d50d49b95e4598e2c9bb65e15e37035bf28.tar.xz
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!
-rw-r--r--sys/src/cmd/nusb/ether/smsc.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/sys/src/cmd/nusb/ether/smsc.c b/sys/src/cmd/nusb/ether/smsc.c
index d5e0427d6..cefdeb2ed 100644
--- a/sys/src/cmd/nusb/ether/smsc.c
+++ b/sys/src/cmd/nusb/ether/smsc.c
@@ -219,7 +219,7 @@ smscread(Dev *ep, uchar *p, int plen)
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;
}