return blobmsg_check_attr_len(attr, name, blob_raw_len(attr));
}
+static const struct blobmsg_hdr* blobmsg_hdr_from_blob(const struct blob_attr *attr, size_t len)
+{
+ if (len < sizeof(struct blob_attr) + sizeof(struct blobmsg_hdr))
+ return NULL;
+
+ return blob_data(attr);
+}
+
+static bool blobmsg_hdr_valid_namelen(const struct blobmsg_hdr *hdr, size_t len)
+{
+ if (len < sizeof(struct blob_attr) + sizeof(struct blobmsg_hdr) + blobmsg_namelen(hdr) + 1)
+ return false;
+
+ return true;
+}
+
static bool blobmsg_check_name(const struct blob_attr *attr, size_t len, bool name)
{
char *limit = (char *) attr + len;
const struct blobmsg_hdr *hdr;
- hdr = blob_data(attr);
+ hdr = blobmsg_hdr_from_blob(attr, len);
+ if (!hdr)
+ return false;
+
if (name && !hdr->namelen)
return false;
- if ((char *) hdr->name + blobmsg_namelen(hdr) > limit)
+ if (name && !blobmsg_hdr_valid_namelen(hdr, len))
+ return false;
+
+ if ((char *) hdr->name + blobmsg_namelen(hdr) + 1 > limit)
return false;
if (blobmsg_namelen(hdr) > (blob_len(attr) - sizeof(struct blobmsg_hdr)))
size_t data_len;
int id;
- if (len < sizeof(struct blob_attr))
- return false;
-
if (!blobmsg_check_name(attr, len, name))
return false;
return 0;
}
-
int blobmsg_parse(const struct blobmsg_policy *policy, int policy_len,
struct blob_attr **tb, void *data, unsigned int len)
{
- struct blobmsg_hdr *hdr;
+ const struct blobmsg_hdr *hdr;
struct blob_attr *attr;
uint8_t *pslen;
int i;
}
__blob_for_each_attr(attr, data, len) {
- hdr = blob_data(attr);
+ hdr = blobmsg_hdr_from_blob(attr, len);
+ if (!hdr)
+ return -1;
+
+ if (!blobmsg_hdr_valid_namelen(hdr, len))
+ return -1;
+
for (i = 0; i < policy_len; i++) {
if (!policy[i].name)
continue;
crash-333757b203a44751d3535f24b05f467183a96d09: blobmsg_parse_array: ... (0)
crash-333757b203a44751d3535f24b05f467183a96d09: blobmsg_parse: ... (0)
crash-333757b203a44751d3535f24b05f467183a96d09: blobmsg_parse_array: ... (0)
- crash-4c4d2c3c9ade5da9347534e290305c3b9760f627: blobmsg_parse: ... (0)
+ crash-4c4d2c3c9ade5da9347534e290305c3b9760f627: blobmsg_parse: ... (-1)
crash-4c4d2c3c9ade5da9347534e290305c3b9760f627: blobmsg_parse_array: ... (-1)
- crash-4c4d2c3c9ade5da9347534e290305c3b9760f627: blobmsg_parse: ... (0)
+ crash-4c4d2c3c9ade5da9347534e290305c3b9760f627: blobmsg_parse: ... (-1)
crash-4c4d2c3c9ade5da9347534e290305c3b9760f627: blobmsg_parse_array: ... (-1)
- crash-5e9937b197c88bf4e7b7ee2612456cad4cb83f5b: blobmsg_parse: ... (0)
+ crash-5e9937b197c88bf4e7b7ee2612456cad4cb83f5b: blobmsg_parse: ... (-1)
crash-5e9937b197c88bf4e7b7ee2612456cad4cb83f5b: blobmsg_parse_array: ... (-1)
- crash-5e9937b197c88bf4e7b7ee2612456cad4cb83f5b: blobmsg_parse: ... (0)
+ crash-5e9937b197c88bf4e7b7ee2612456cad4cb83f5b: blobmsg_parse: ... (-1)
crash-5e9937b197c88bf4e7b7ee2612456cad4cb83f5b: blobmsg_parse_array: ... (-1)
- crash-75b146c4e6fac64d3e62236b27c64b50657bab2a: blobmsg_parse: ... (0)
+ crash-75b146c4e6fac64d3e62236b27c64b50657bab2a: blobmsg_parse: ... (-1)
crash-75b146c4e6fac64d3e62236b27c64b50657bab2a: blobmsg_parse_array: ... (-1)
- crash-75b146c4e6fac64d3e62236b27c64b50657bab2a: blobmsg_parse: ... (0)
+ crash-75b146c4e6fac64d3e62236b27c64b50657bab2a: blobmsg_parse: ... (-1)
crash-75b146c4e6fac64d3e62236b27c64b50657bab2a: blobmsg_parse_array: ... (-1)
- crash-813f3e68661da09c26d4a87dbb9d5099e92be50f: blobmsg_parse: ... (0)
+ crash-813f3e68661da09c26d4a87dbb9d5099e92be50f: blobmsg_parse: ... (-1)
crash-813f3e68661da09c26d4a87dbb9d5099e92be50f: blobmsg_parse_array: ... (-1)
- crash-813f3e68661da09c26d4a87dbb9d5099e92be50f: blobmsg_parse: ... (0)
+ crash-813f3e68661da09c26d4a87dbb9d5099e92be50f: blobmsg_parse: ... (-1)
crash-813f3e68661da09c26d4a87dbb9d5099e92be50f: blobmsg_parse_array: ... (-1)
crash-98595faa58ba01d85ba4fd0b109cd3d490b45795: blobmsg_parse: ... (0)
crash-98595faa58ba01d85ba4fd0b109cd3d490b45795: blobmsg_parse_array: ... (0)
crash-98595faa58ba01d85ba4fd0b109cd3d490b45795: blobmsg_parse: ... (0)
crash-98595faa58ba01d85ba4fd0b109cd3d490b45795: blobmsg_parse_array: ... (0)
+ crash-a3585b70f1c7ffbdec10f6dadc964336118485c4: blobmsg_parse: ... (-1)
+ crash-a3585b70f1c7ffbdec10f6dadc964336118485c4: blobmsg_parse_array: ... (-1)
+ crash-a3585b70f1c7ffbdec10f6dadc964336118485c4: blobmsg_parse: ... (-1)
+ crash-a3585b70f1c7ffbdec10f6dadc964336118485c4: blobmsg_parse_array: ... (-1)
+ crash-b3585b70f1c7ffbdec10f6dadc964336118485c4: blobmsg_parse: ... (-1)
+ crash-b3585b70f1c7ffbdec10f6dadc964336118485c4: blobmsg_parse_array: ... (-1)
+ crash-b3585b70f1c7ffbdec10f6dadc964336118485c4: blobmsg_parse: ... (-1)
+ crash-b3585b70f1c7ffbdec10f6dadc964336118485c4: blobmsg_parse_array: ... (-1)
crash-d0f3aa7d60a094b021f635d4edb7807c055a4ea1: blobmsg_parse: ... (0)
crash-d0f3aa7d60a094b021f635d4edb7807c055a4ea1: blobmsg_parse_array: ... (0)
crash-d0f3aa7d60a094b021f635d4edb7807c055a4ea1: blobmsg_parse: ... (0)
crash-d0f3aa7d60a094b021f635d4edb7807c055a4ea1: blobmsg_parse_array: ... (0)
- crash-df9d1243057b27bbad6211e5a23d1cb699028aa2: blobmsg_parse: ... (0)
+ crash-df9d1243057b27bbad6211e5a23d1cb699028aa2: blobmsg_parse: ... (-1)
crash-df9d1243057b27bbad6211e5a23d1cb699028aa2: blobmsg_parse_array: ... (0)
- crash-df9d1243057b27bbad6211e5a23d1cb699028aa2: blobmsg_parse: ... (0)
+ crash-df9d1243057b27bbad6211e5a23d1cb699028aa2: blobmsg_parse: ... (-1)
crash-df9d1243057b27bbad6211e5a23d1cb699028aa2: blobmsg_parse_array: ... (0)
- crash-e2fd5ecb3b37926743256f1083f47a07c39e10c2: blobmsg_parse: ... (0)
+ crash-e2fd5ecb3b37926743256f1083f47a07c39e10c2: blobmsg_parse: ... (-1)
crash-e2fd5ecb3b37926743256f1083f47a07c39e10c2: blobmsg_parse_array: ... (-1)
- crash-e2fd5ecb3b37926743256f1083f47a07c39e10c2: blobmsg_parse: ... (0)
+ crash-e2fd5ecb3b37926743256f1083f47a07c39e10c2: blobmsg_parse: ... (-1)
crash-e2fd5ecb3b37926743256f1083f47a07c39e10c2: blobmsg_parse_array: ... (-1)
valid-blobmsg.bin: blobmsg_parse: MLT (0)
valid-blobmsg.bin: blobmsg_parse_array: MLT (0)