blob: validate strings on parse
authorFelix Fietkau <nbd@openwrt.org>
Mon, 31 Jan 2011 02:30:41 +0000 (03:30 +0100)
committerFelix Fietkau <nbd@openwrt.org>
Mon, 31 Jan 2011 02:32:28 +0000 (03:32 +0100)
blob.c

diff --git a/blob.c b/blob.c
index 89ed31ace089aa8fd1b0be15e289f420a556fe28..3bd69fac04d43043172b7bd6032dc9529974c049 100644 (file)
--- a/blob.c
+++ b/blob.c
@@ -142,6 +142,7 @@ blob_parse(struct blob_attr *attr, struct blob_attr **data, const struct blob_at
        blob_for_each_attr(pos, attr, rem) {
                int id = blob_id(pos);
                int len = blob_len(pos);
+               char *pdata;
 
                if (id >= max)
                        continue;
@@ -158,6 +159,10 @@ blob_parse(struct blob_attr *attr, struct blob_attr **data, const struct blob_at
                                }
                        }
 
+                       pdata = blob_data(pos);
+                       if (type == BLOB_ATTR_STRING && pdata[len] != 0)
+                               continue;
+
                        if (info[id].minlen && len < info[id].minlen)
                                continue;