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"
This commit is contained in:
cinap_lenrek 2013-06-17 02:28:10 +02:00
parent 202be57bb9
commit bf048d94c3

View file

@ -354,11 +354,12 @@ etherread4(void *a)
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 @@ etherread6(void *a)
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();
}