diff options
author | Kenjiro Cho <kjc@cvs.openbsd.org> | 2003-03-11 02:26:00 +0000 |
---|---|---|
committer | Kenjiro Cho <kjc@cvs.openbsd.org> | 2003-03-11 02:26:00 +0000 |
commit | 67638b1fc31d9cb577e822fcc385b0a5b6b5f221 (patch) | |
tree | 2a2f3e20e980227121f30c49f1d37d36c5157ad9 | |
parent | 36badee22101cf38d93e7d82012b73a2a05c5d97 (diff) |
add protection against packets without pkthdr.
this should not happen but just in case.
printf() is intended to be annoying so that we'll get reports on it.
original idea from dhartmei@
ok deraadt@, henning@
-rw-r--r-- | sys/altq/altq_cbq.c | 9 | ||||
-rw-r--r-- | sys/altq/altq_hfsc.c | 9 | ||||
-rw-r--r-- | sys/altq/altq_priq.c | 9 |
3 files changed, 24 insertions, 3 deletions
diff --git a/sys/altq/altq_cbq.c b/sys/altq/altq_cbq.c index 0eb98af1dfd..70db136f942 100644 --- a/sys/altq/altq_cbq.c +++ b/sys/altq/altq_cbq.c @@ -1,4 +1,4 @@ -/* $OpenBSD: altq_cbq.c,v 1.13 2003/03/02 11:22:31 henning Exp $ */ +/* $OpenBSD: altq_cbq.c,v 1.14 2003/03/11 02:25:59 kjc Exp $ */ /* $KAME: altq_cbq.c,v 1.9 2000/12/14 08:12:45 thorpej Exp $ */ /* @@ -492,6 +492,13 @@ cbq_enqueue(struct ifaltq *ifq, struct mbuf *m, struct altq_pktattr *pktattr) int len; /* grab class set by classifier */ + if ((m->m_flags & M_PKTHDR) == 0) { + /* should not happen */ + printf("altq: packet for %s does not have pkthdr\n", + ifq->altq_ifp->if_xname); + m_freem(m); + return (ENOBUFS); + } t = m_tag_find(m, PACKET_TAG_PF_QID, NULL); if (t == NULL || (cl = clh_to_clp(cbqp, ((struct altq_tag *)(t+1))->qid)) == NULL) { diff --git a/sys/altq/altq_hfsc.c b/sys/altq/altq_hfsc.c index eb844cb7daa..369b6c8f240 100644 --- a/sys/altq/altq_hfsc.c +++ b/sys/altq/altq_hfsc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: altq_hfsc.c,v 1.10 2003/03/02 11:22:31 henning Exp $ */ +/* $OpenBSD: altq_hfsc.c,v 1.11 2003/03/11 02:25:59 kjc Exp $ */ /* $KAME: altq_hfsc.c,v 1.17 2002/11/29 07:48:33 kjc Exp $ */ /* @@ -615,6 +615,13 @@ hfsc_enqueue(ifq, m, pktattr) int len; /* grab class set by classifier */ + if ((m->m_flags & M_PKTHDR) == 0) { + /* should not happen */ + printf("altq: packet for %s does not have pkthdr\n", + ifq->altq_ifp->if_xname); + m_freem(m); + return (ENOBUFS); + } t = m_tag_find(m, PACKET_TAG_PF_QID, NULL); if (t == NULL || (cl = clh_to_clp(hif, ((struct altq_tag *)(t+1))->qid)) == NULL || diff --git a/sys/altq/altq_priq.c b/sys/altq/altq_priq.c index 109686b4826..29acd1ce910 100644 --- a/sys/altq/altq_priq.c +++ b/sys/altq/altq_priq.c @@ -1,4 +1,4 @@ -/* $OpenBSD: altq_priq.c,v 1.10 2003/03/02 11:22:31 henning Exp $ */ +/* $OpenBSD: altq_priq.c,v 1.11 2003/03/11 02:25:59 kjc Exp $ */ /* $KAME: altq_priq.c,v 1.1 2000/10/18 09:15:23 kjc Exp $ */ /* * Copyright (C) 2000 @@ -409,6 +409,13 @@ priq_enqueue(struct ifaltq *ifq, struct mbuf *m, struct altq_pktattr *pktattr) int len; /* grab class set by classifier */ + if ((m->m_flags & M_PKTHDR) == 0) { + /* should not happen */ + printf("altq: packet for %s does not have pkthdr\n", + ifq->altq_ifp->if_xname); + m_freem(m); + return (ENOBUFS); + } t = m_tag_find(m, PACKET_TAG_PF_QID, NULL); if (t == NULL || (cl = clh_to_clp(pif, ((struct altq_tag *)(t+1))->qid)) == NULL) { |