mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2025-01-18 12:52:44 +01:00
gnrc_sixlowpan_iphc: fix _compressible()
When either `gnrc_sixlowpan_iphc_nhc` or `gnrc_udp` is not compiled in `_compressible()` never returns `true`. This causes the `dispatch` snip in `gnrc_sixlowpan_iphc_send()` to be of length 0, meaning `dispatch->data` is `NULL`, causing possible crashes when trying to send IPv6 packets over 6LoWPAN without NHC or UDP.
This commit is contained in:
parent
7220b66708
commit
43c2c728c9
@ -647,8 +647,8 @@ static inline bool _compressible(gnrc_pktsnip_t *hdr)
|
||||
case GNRC_NETTYPE_IPV6:
|
||||
#if defined(MODULE_GNRC_SIXLOWPAN_IPHC_NHC) && defined(MODULE_GNRC_UDP)
|
||||
case GNRC_NETTYPE_UDP:
|
||||
return true;
|
||||
#endif
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
@ -705,6 +705,9 @@ void gnrc_sixlowpan_iphc_send(gnrc_pktsnip_t *pkt, void *ctx, unsigned page)
|
||||
dispatch = ptr; /* use dispatch as temporary point for prev */
|
||||
ptr = ptr->next;
|
||||
}
|
||||
/* there should be at least one compressible header in `pkt`, otherwise this
|
||||
* function should not be called */
|
||||
assert(dispatch_size > 0);
|
||||
ipv6_hdr = pkt->next->data;
|
||||
dispatch = gnrc_pktbuf_add(NULL, NULL, dispatch_size,
|
||||
GNRC_NETTYPE_SIXLOWPAN);
|
||||
|
Loading…
Reference in New Issue
Block a user