CVE-2022-32745 s4/dsdb/samldb: Check for empty values array
authorJoseph Sutton <josephsutton@catalyst.net.nz>
Wed, 16 Feb 2022 04:03:10 +0000 (17:03 +1300)
committerJule Anger <janger@samba.org>
Wed, 27 Jul 2022 10:52:36 +0000 (10:52 +0000)
This avoids potentially trying to access the first element of an empty
array.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=15008

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
source4/dsdb/samdb/ldb_modules/samldb.c

index b89d93910fd24927daf7a1b6b33a4dc715bdb509..3ecbd00e68e26fab1a6b82157b71a20578cf35bb 100644 (file)
@@ -751,7 +751,7 @@ static int samldb_schema_add_handle_linkid(struct samldb_ctx *ac)
                return ret;
        }
 
-       if (el == NULL) {
+       if (el == NULL || el->num_values == 0) {
                return LDB_SUCCESS;
        }
 
@@ -919,7 +919,7 @@ static int samldb_schema_add_handle_mapiid(struct samldb_ctx *ac)
                return ret;
        }
 
-       if (el == NULL) {
+       if (el == NULL || el->num_values == 0) {
                return LDB_SUCCESS;
        }