]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
s4:dsdb:strcasecmp_with_ldb_val() avoids overflow
authorDouglas Bagnall <douglas.bagnall@catalyst.net.nz>
Sun, 12 May 2024 23:08:35 +0000 (11:08 +1200)
committerAndrew Bartlett <abartlet@samba.org>
Wed, 22 May 2024 23:12:32 +0000 (23:12 +0000)
In the unlikely event that strlen(str) > INT_MAX, the result could
have overflowed.

This is not a sort transitivity issue, as this is not a symmetric sort
comparison, but it would affect binary search reliability.

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
source4/dsdb/schema/schema_query.c

index 0721e990ac0df418aac712a45d6f21b5192bfa5b..736027975ea872875945645417f21a92e89e1681 100644 (file)
@@ -52,7 +52,9 @@ static int strcasecmp_with_ldb_val(const struct ldb_val *target, const char *str
                        }
                        return 1;
                }
-               return (target->length - len);
+               if (target->length < len) {
+                       return -1;
+               }
        }
        return ret;
 }