From bf048d94c35c78081fa1a3cfdca8de16ad640325 Mon Sep 17 00:00:00 2001 From: cinap_lenrek Date: Mon, 17 Jun 2013 02:28:10 +0200 Subject: 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" --- sys/src/9/ip/ethermedium.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'sys/src/9/ip/ethermedium.c') diff --git a/sys/src/9/ip/ethermedium.c b/sys/src/9/ip/ethermedium.c index 1aab2b9ec..f5b4e855d 100644 --- a/sys/src/9/ip/ethermedium.c +++ b/sys/src/9/ip/ethermedium.c @@ -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(); } -- cgit v1.2.3