From: Douglas Bagnall Date: Sun, 12 May 2024 23:08:35 +0000 (+1200) Subject: s4:dsdb:strcasecmp_with_ldb_val() avoids overflow X-Git-Tag: tdb-1.4.11~553 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=a00c0ebd090f69f94ce6ba7774a9fc126d7de504;p=thirdparty%2Fsamba.git s4:dsdb:strcasecmp_with_ldb_val() avoids overflow 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 Reviewed-by: Andrew Bartlett --- diff --git a/source4/dsdb/schema/schema_query.c b/source4/dsdb/schema/schema_query.c index 0721e990ac0..736027975ea 100644 --- a/source4/dsdb/schema/schema_query.c +++ b/source4/dsdb/schema/schema_query.c @@ -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; }