Code

store_lookup: Don't accept invalid object types in parse_cmp().
authorSebastian Harl <sh@tokkee.org>
Mon, 23 Jun 2014 07:12:11 +0000 (09:12 +0200)
committerSebastian Harl <sh@tokkee.org>
Mon, 23 Jun 2014 07:12:11 +0000 (09:12 +0200)
Added a unit-test catching that.

src/core/store_lookup.c
t/unit/core/store_lookup_test.c

index 100942ac8ab652fc21c9d2691e9517ca28564c81..dceab19dd7d99feb1e7fb68982d43fe703567e00 100644 (file)
@@ -683,6 +683,8 @@ sdb_store_matcher_parse_cmp(const char *obj_type, const char *attr,
                type = SDB_SERVICE;
        else if (! strcasecmp(obj_type, "attribute"))
                type = SDB_ATTRIBUTE;
+       else
+               return NULL;
 
        /* TODO: support other operators */
        if (! strcasecmp(op, "=")) {
index c125a5913a407c1e177998864d740d1427933d1d..67f2e05cbeff6bf31f301fd938a7b1202bbb92da 100644 (file)
@@ -421,6 +421,8 @@ START_TEST(test_parse_cmp)
                { "attribute", "attr", "=~", "attrname", MATCHER_ATTR },
                { "attribute", "attr", "!~", "attrname", MATCHER_NOT },
                { "attribute", "attr", "&^", "attrname", -1 },
+               { "foo",       "name", "=",  "bar",      -1 },
+               { "foo",       "attr", "=",  "bar",      -1 },
        };
 
        for (i = 0; i < SDB_STATIC_ARRAY_LEN(golden_data); ++i) {