From 596bcf4487836a640a03ccbad28763694181cab4 Mon Sep 17 00:00:00 2001 From: Sebastian Harl Date: Mon, 23 Jun 2014 09:12:11 +0200 Subject: [PATCH] store_lookup: Don't accept invalid object types in parse_cmp(). Added a unit-test catching that. --- src/core/store_lookup.c | 2 ++ t/unit/core/store_lookup_test.c | 2 ++ 2 files changed, 4 insertions(+) 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) { -- 2.30.2