ref: bf048d94c35c78081fa1a3cfdca8de16ad640325
parent: 202be57bb94b2bd65db9164bfd94ad2ec5167071
author: cinap_lenrek <cinap_lenrek@gmx.de>
date: Sun Jun 16 22:28:10 EDT 2013
ip/ethermedium: drop short packets instead of producing negative size blocks on usb ethernet, it can happen that we read truncated packets smaller than the ethernet header size. this produces a warning in pullupblock() later like: "pullup negative length packet, called from 0xf0199e46"
--- a/sys/src/9/ip/ethermedium.c
+++ b/sys/src/9/ip/ethermedium.c
@@ -354,11 +354,12 @@
nexterror();
}
ifc->in++;
- bp->rp += ifc->m->hsize;
- if(ifc->lifc == nil)
+ if(ifc->lifc == nil || BLEN(bp) <= ifc->m->hsize)
freeb(bp);
- else
+ else {+ bp->rp += ifc->m->hsize;
ipiput4(er->f, ifc, bp);
+ }
runlock(ifc);
poperror();
}
@@ -393,11 +394,12 @@
nexterror();
}
ifc->in++;
- bp->rp += ifc->m->hsize;
- if(ifc->lifc == nil)
+ if(ifc->lifc == nil || BLEN(bp) <= ifc->m->hsize)
freeb(bp);
- else
+ else {+ bp->rp += ifc->m->hsize;
ipiput6(er->f, ifc, bp);
+ }
runlock(ifc);
poperror();
}
--
⑨