From cd65ce8a18b9ea9a8ce2338bc02c1b3e8ee10225 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Thu, 7 Jan 2010 17:27:03 +1100 Subject: s4-schema: make ldb_val to string comparison safer with nul termination Pair-Programmed-With: Andrew Bartlett --- source4/dsdb/schema/schema_query.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'source4/dsdb/schema') diff --git a/source4/dsdb/schema/schema_query.c b/source4/dsdb/schema/schema_query.c index 907c671257..75d9716070 100644 --- a/source4/dsdb/schema/schema_query.c +++ b/source4/dsdb/schema/schema_query.c @@ -39,7 +39,14 @@ static int strcasecmp_with_ldb_val(const struct ldb_val *target, const char *str { int ret = strncasecmp((const char *)target->data, str, target->length); if (ret == 0) { - return (target->length - strlen(str)); + size_t len = strlen(str); + if (target->length > len) { + if (target->data[len] == 0) { + return 0; + } + return 1; + } + return (target->length - len); } return ret; } -- cgit