From e509c101fe72cbffe6b339754178d6b44363c886 Mon Sep 17 00:00:00 2001 From: Martine Lenders Date: Tue, 26 May 2015 20:20:02 +0200 Subject: [PATCH] ng_ipv6_ext: exit early on invalid size --- sys/net/network_layer/ng_ipv6/ext/ng_ipv6_ext.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/sys/net/network_layer/ng_ipv6/ext/ng_ipv6_ext.c b/sys/net/network_layer/ng_ipv6/ext/ng_ipv6_ext.c index 8919291e0f..1f746e0ad0 100644 --- a/sys/net/network_layer/ng_ipv6/ext/ng_ipv6_ext.c +++ b/sys/net/network_layer/ng_ipv6/ext/ng_ipv6_ext.c @@ -71,6 +71,10 @@ ng_pktsnip_t *ng_ipv6_ext_build(ng_pktsnip_t *ipv6, ng_pktsnip_t *next, ng_pktsnip_t *prev = NULL, *snip; ng_ipv6_ext_t *ext; + if (size < NG_IPV6_EXT_LEN_UNIT) { + return NULL; + } + if (ipv6 != NULL) { LL_SEARCH_SCALAR(ipv6, prev, next, next); @@ -79,10 +83,6 @@ ng_pktsnip_t *ng_ipv6_ext_build(ng_pktsnip_t *ipv6, ng_pktsnip_t *next, } } - if (size < NG_IPV6_EXT_LEN_UNIT) { - return NULL; - } - snip = ng_pktbuf_add(next, NULL, size, NG_NETTYPE_IPV6); if (snip == NULL) {