summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Gwynne <dlg@cvs.openbsd.org>2019-08-16 04:09:03 +0000
committerDavid Gwynne <dlg@cvs.openbsd.org>2019-08-16 04:09:03 +0000
commit7578bdf179c7036fa48c0d5b572924810eb8eaac (patch)
treeb587c141a49ab422b249c793c687c8e449fb84b3
parentf4d81b40d01e780385e79f509dc699e74e43586b (diff)
ifq_hdatalen should keep the mbuf it's looking at, not leak it.
ie, use ifq_deq_rollback after looking at the head mbuf instead of ifq_deq_commit. this is used in tun/tap, where it had the effect that you'd get the datalen for the packet, and then when you try to read that many bytes it had gone. cool and normal. this was found by a student who was trying to do just that. i've always just read the packet into a large buffer.
-rw-r--r--sys/net/ifq.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/sys/net/ifq.c b/sys/net/ifq.c
index 302277c2e7b..20ad6c14b5e 100644
--- a/sys/net/ifq.c
+++ b/sys/net/ifq.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ifq.c,v 1.33 2019/07/03 10:19:45 dlg Exp $ */
+/* $OpenBSD: ifq.c,v 1.34 2019/08/16 04:09:02 dlg Exp $ */
/*
* Copyright (c) 2015 David Gwynne <dlg@openbsd.org>
@@ -397,7 +397,7 @@ ifq_hdatalen(struct ifqueue *ifq)
m = ifq_deq_begin(ifq);
if (m != NULL) {
len = m->m_pkthdr.len;
- ifq_deq_commit(ifq, m);
+ ifq_deq_rollback(ifq, m);
}
return (len);