Skip to content
Snippets Groups Projects
Commit a09b144e authored by Anjan Chanda's avatar Anjan Chanda
Browse files

fix potential buffer overflow in tlv_ok()

parent 95f2d6d1
Branches
No related tags found
No related merge requests found
...@@ -101,11 +101,16 @@ void tlv_free_linear(struct tlv *t) ...@@ -101,11 +101,16 @@ void tlv_free_linear(struct tlv *t)
int tlv_ok(struct tlv *t, int rem) int tlv_ok(struct tlv *t, int rem)
{ {
uint16_t l = buf_get_be16(&((uint8_t *)t)[1]); uint16_t l;
if (rem >= sizeof(struct tlv) && l <= rem - 3)
return 1;
return 0; if (rem < sizeof(struct tlv))
return 0;
l = buf_get_be16(&((uint8_t *)t)[1]);
if (l + 3 > rem)
return 0;
return 1;
} }
struct tlv *tlv_next(struct tlv *t, int *rem) struct tlv *tlv_next(struct tlv *t, int *rem)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment