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

allow zero padded cmdus

parent 4b45985f
No related branches found
No related tags found
No related merge requests found
Pipeline #44061 passed
...@@ -607,8 +607,14 @@ int cmdu_parse_tlv_single(struct cmdu_buff *c, struct tlv *tv[], ...@@ -607,8 +607,14 @@ int cmdu_parse_tlv_single(struct cmdu_buff *c, struct tlv *tv[],
} }
/* malformed cmdu if data remaining */ /* malformed cmdu if data remaining */
if (len) if (len) {
return -1; int k = 0;
while (k < len) {
if (c->data[c->datalen - len + k++] != 0)
return -1;
}
}
/* exactly one tlv must be present */ /* exactly one tlv must be present */
if (policy->present == TLV_PRESENT_ONE && !tv[0]) if (policy->present == TLV_PRESENT_ONE && !tv[0])
...@@ -661,9 +667,15 @@ int cmdu_parse_tlvs(struct cmdu_buff *c, struct tlv *tv[][16], ...@@ -661,9 +667,15 @@ int cmdu_parse_tlvs(struct cmdu_buff *c, struct tlv *tv[][16],
} }
} }
/* malformed cmdu if data remaining */ /* malformed cmdu if data remaining; only allow zero padding */
if (len) if (len) {
return -1; int k = 0;
while (k < len) {
if (c->data[c->datalen - len + k++] != 0)
return -1;
}
}
/* strictly check against tlv policies */ /* strictly check against tlv policies */
for (i = 0; i < policy_len; i++) { for (i = 0; i < policy_len; i++) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment