summaryrefslogtreecommitdiff
path: root/sys/src/9/ip
diff options
context:
space:
mode:
authorcinap_lenrek <cinap_lenrek@gmx.de>2013-06-17 02:28:10 +0200
committercinap_lenrek <cinap_lenrek@gmx.de>2013-06-17 02:28:10 +0200
commitbf048d94c35c78081fa1a3cfdca8de16ad640325 (patch)
treeb00fc28bf96c2209a73922078d2b8d829942a2c4 /sys/src/9/ip
parent202be57bb94b2bd65db9164bfd94ad2ec5167071 (diff)
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"
Diffstat (limited to 'sys/src/9/ip')
-rw-r--r--sys/src/9/ip/ethermedium.c14
1 files changed, 8 insertions, 6 deletions
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();
}