Skip to content
Snippets Groups Projects
Commit 2f94d669 authored by Johann Fischer's avatar Johann Fischer
Browse files

gnrc_pktbuf_static.c: fix overflow in gnrc_pktbuf_realloc_data

This patch fixes overflow, which is caused by
(pkt->size - aligned_size). This happens if pkt->size and
new size are unaligned and the difference
between pkt->size and new size is less than four.
parent 26f9f7fa
No related branches found
No related tags found
No related merge requests found
...@@ -179,8 +179,10 @@ int gnrc_pktbuf_realloc_data(gnrc_pktsnip_t *pkt, size_t size) ...@@ -179,8 +179,10 @@ int gnrc_pktbuf_realloc_data(gnrc_pktsnip_t *pkt, size_t size)
pkt->data = new_data; pkt->data = new_data;
} }
else { else {
_pktbuf_free(((uint8_t *)pkt->data) + aligned_size, if (_align(pkt->size) > aligned_size) {
pkt->size - aligned_size); _pktbuf_free(((uint8_t *)pkt->data) + aligned_size,
pkt->size - aligned_size);
}
} }
pkt->size = size; pkt->size = size;
mutex_unlock(&_mutex); mutex_unlock(&_mutex);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment