ldb: fix the canonicalisation of booleans
authorAndrew Tridgell <tridge@samba.org>
Tue, 9 Aug 2011 06:41:16 +0000 (16:41 +1000)
committerAndrew Bartlett <abartlet@samba.org>
Tue, 9 Aug 2011 09:56:23 +0000 (11:56 +0200)
we were canonicalising "FALSE" to "FALS"

Pair-Programmed-With: Andrew Bartlett <abartlet@samba.org>

lib/ldb/common/attrib_handlers.c

index 2f4454c7b41eae4351395c868b269b9d03f751af..73e1705593bf1d9db2bb3b88f3a3e82723855696 100644 (file)
@@ -166,12 +166,12 @@ static int ldb_comparison_Integer(struct ldb_context *ldb, void *mem_ctx,
 static int ldb_canonicalise_Boolean(struct ldb_context *ldb, void *mem_ctx,
                             const struct ldb_val *in, struct ldb_val *out)
 {
-       if (strncasecmp((char *)in->data, "TRUE", in->length) == 0) {
+       if (in->length >= 4 && strncasecmp((char *)in->data, "TRUE", in->length) == 0) {
                out->data = (uint8_t *)talloc_strdup(mem_ctx, "TRUE");
                out->length = 4;
-       } else if (strncasecmp((char *)in->data, "FALSE", in->length) == 0) {
+       } else if (in->length >= 5 && strncasecmp((char *)in->data, "FALSE", in->length) == 0) {
                out->data = (uint8_t *)talloc_strdup(mem_ctx, "FALSE");
-               out->length = 4;
+               out->length = 5;
        } else {
                return -1;
        }