contiki-os / contiki

The official git repository for Contiki, the open source OS for the Internet of Things
http://www.contiki-os.org/
Other
3.71k stars 2.58k forks source link

ICMPv6 Echo Reply callback - wrong data passed to the callback #2107

Open thesalmon opened 7 years ago

thesalmon commented 7 years ago

After that an ECHO Reply ICMPv6 message is being processed the callback is called in this way:

n->callback(&sender, ttl,
    (uint8_t *)&UIP_ICMP_BUF[sizeof(struct uip_icmp_hdr)],
    uip_len - sizeof(struct uip_icmp_hdr) - UIP_IPH_LEN);

However the index sizeof(struct uip_icmp_hdr) in UIP_ICMP_BUF does not point to the beginning of the ICMPv6 payload, due to the definition of UIP_ICMP_BUF:

#define UIP_ICMP_BUF ((struct uip_icmp_hdr *)&uip_buf[uip_l2_l3_hdr_len])
thesalmon commented 7 years ago

If I'm not wrong the following should fix it:

n->callback(&sender, ttl,
    &((uint8_t *)UIP_ICMP_BUF)[sizeof(struct uip_icmp_hdr)],
    uip_len - sizeof(struct uip_icmp_hdr) - UIP_IPH_LEN);