Code

store_lookup: Don't allow 'IS <non-NULL>'.
authorSebastian Harl <sh@tokkee.org>
Mon, 21 Jul 2014 07:16:44 +0000 (09:16 +0200)
committerSebastian Harl <sh@tokkee.org>
Mon, 21 Jul 2014 07:16:44 +0000 (09:16 +0200)
This would have been silently treated as 'IS NULL'.

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

index 317be555b7be0560833fd056e47daf8e1d0e72e7..da9f55076f6d5a1fc33969bee7012d3fb6ea6856 100644 (file)
@@ -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, "<"))
index d6a71e566aea8e0919819984cec6814d55ef0c82..7536f390bc96cfe9b556326271925c367ff6d0a7 100644 (file)
@@ -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 },
        };