From: Sebastian Harl Date: Mon, 23 Jun 2014 07:12:11 +0000 (+0200) Subject: store_lookup: Don't accept invalid object types in parse_cmp(). X-Git-Tag: sysdb-0.2.0~39^2~2 X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=596bcf4487836a640a03ccbad28763694181cab4;p=sysdb.git store_lookup: Don't accept invalid object types in parse_cmp(). Added a unit-test catching that. --- diff --git a/src/core/store_lookup.c b/src/core/store_lookup.c index 100942a..dceab19 100644 --- a/src/core/store_lookup.c +++ b/src/core/store_lookup.c @@ -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, "=")) { diff --git a/t/unit/core/store_lookup_test.c b/t/unit/core/store_lookup_test.c index c125a59..67f2e05 100644 --- a/t/unit/core/store_lookup_test.c +++ b/t/unit/core/store_lookup_test.c @@ -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) {