diff options
author | sam <sam@FreeBSD.org> | 2005-02-24 00:40:33 +0000 |
---|---|---|
committer | sam <sam@FreeBSD.org> | 2005-02-24 00:40:33 +0000 |
commit | 4a79dc0d43befe55f2c9f83a4ea84580531b1d19 (patch) | |
tree | dd38613010cf85c1dfc97610e3619716d2862419 /sys/kern/uipc_mbuf.c | |
parent | 9b55c7654adbcbf2a775e582e9e08eac9c10c107 (diff) | |
download | FreeBSD-src-4a79dc0d43befe55f2c9f83a4ea84580531b1d19.zip FreeBSD-src-4a79dc0d43befe55f2c9f83a4ea84580531b1d19.tar.gz |
change m_adj to reclaim unused mbufs instead of zero'ing m_len
when trim'ing space off the back of a chain; this is indirect
solution to a potential null ptr deref
Noticed by: Coverity Prevent analysis tool (null ptr deref)
Reviewed by: dg, rwatson
Diffstat (limited to 'sys/kern/uipc_mbuf.c')
-rw-r--r-- | sys/kern/uipc_mbuf.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/sys/kern/uipc_mbuf.c b/sys/kern/uipc_mbuf.c index aece312..4d832a8 100644 --- a/sys/kern/uipc_mbuf.c +++ b/sys/kern/uipc_mbuf.c @@ -691,12 +691,14 @@ m_adj(struct mbuf *mp, int req_len) for (; m; m = m->m_next) { if (m->m_len >= count) { m->m_len = count; + if (m->m_next != NULL) { + m_freem(m->m_next); + m->m_next = NULL; + } break; } count -= m->m_len; } - while (m->m_next) - (m = m->m_next) ->m_len = 0; } } |