From: Sebastian Harl Date: Mon, 21 Jul 2014 07:16:44 +0000 (+0200) Subject: store_lookup: Don't allow 'IS '. X-Git-Tag: sysdb-0.3.0~36 X-Git-Url: https://git.tokkee.org/?p=sysdb.git;a=commitdiff_plain;h=ea9e77cb6bee990c4087a8cefc9d8cc2311b39d1 store_lookup: Don't allow 'IS '. This would have been silently treated as 'IS NULL'. --- diff --git a/src/core/store_lookup.c b/src/core/store_lookup.c index 317be55..da9f550 100644 --- a/src/core/store_lookup.c +++ b/src/core/store_lookup.c @@ -737,8 +737,12 @@ parse_attr_cmp(const char *attr, const char *op, const sdb_data_t *value) if (! strcasecmp(attr, "name")) return NULL; - if (! strcasecmp(op, "IS")) - return sdb_store_isnull_matcher(attr); + if (! strcasecmp(op, "IS")) { + if (! value) + return sdb_store_isnull_matcher(attr); + else + return NULL; + } else if (! value) return NULL; else if (! strcasecmp(op, "<")) diff --git a/t/unit/core/store_lookup_test.c b/t/unit/core/store_lookup_test.c index d6a71e5..7536f39 100644 --- a/t/unit/core/store_lookup_test.c +++ b/t/unit/core/store_lookup_test.c @@ -451,6 +451,7 @@ START_TEST(test_parse_cmp) { "attribute", "attr", ">=", &attrname, MATCHER_GE }, { "attribute", "attr", ">", &attrname, MATCHER_GT }, { "attribute", "attr", "IS", NULL, MATCHER_ISNULL }, + { "attribute", "attr", "IS", &attrname, -1 }, { "foo", "name", "=", &attrname, -1 }, { "foo", "attr", "=", &attrname, -1 }, };