summaryrefslogtreecommitdiff
path: root/lib/librte_mbuf
diff options
context:
space:
mode:
authorDavid Marchand <david.marchand@6wind.com>2019-01-07 09:57:10 +0100
committerThomas Monjalon <thomas@monjalon.net>2019-01-15 02:40:40 +0100
commitdcd2a33d3c8a9ce845eb4e9e8abac0a39efe0b80 (patch)
tree6432cb3aed91af7244ad92dcc2b3729fe8d2caa1 /lib/librte_mbuf
parenta1e8241a919f7239d16e63fbc41549b2c951e1ae (diff)
downloaddpdk-dcd2a33d3c8a9ce845eb4e9e8abac0a39efe0b80.zip
dpdk-dcd2a33d3c8a9ce845eb4e9e8abac0a39efe0b80.tar.gz
dpdk-dcd2a33d3c8a9ce845eb4e9e8abac0a39efe0b80.tar.xz
mbuf: add sanity checks on segment metadata
Add some basic checks on the segments offset and length metadata: always funny to have a < 0 tailroom cast to uint16_t ;-). Signed-off-by: David Marchand <david.marchand@6wind.com> Signed-off-by: David Marchand <david.marchand@redhat.com> Acked-by: Olivier Matz <olivier.matz@6wind.com>
Diffstat (limited to 'lib/librte_mbuf')
-rw-r--r--lib/librte_mbuf/rte_mbuf.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/lib/librte_mbuf/rte_mbuf.c b/lib/librte_mbuf/rte_mbuf.c
index 9790b4f..3bbd3f5 100644
--- a/lib/librte_mbuf/rte_mbuf.c
+++ b/lib/librte_mbuf/rte_mbuf.c
@@ -200,6 +200,10 @@ rte_mbuf_sanity_check(const struct rte_mbuf *m, int is_header)
pkt_len = m->pkt_len;
do {
+ if (m->data_off > m->buf_len)
+ rte_panic("data offset too big in mbuf segment\n");
+ if (m->data_off + m->data_len > m->buf_len)
+ rte_panic("data length too big in mbuf segment\n");
nb_segs -= 1;
pkt_len -= m->data_len;
} while ((m = m->next) != NULL);