From ea9e77cb6bee990c4087a8cefc9d8cc2311b39d1 Mon Sep 17 00:00:00 2001 From: Sebastian Harl Date: Mon, 21 Jul 2014 09:16:44 +0200 Subject: [PATCH] store_lookup: Don't allow 'IS '. This would have been silently treated as 'IS NULL'. --- src/core/store_lookup.c | 8 ++++++-- t/unit/core/store_lookup_test.c | 1 + 2 files changed, 7 insertions(+), 2 deletions(-) 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 }, }; -- 2.30.2