summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2010-01-07 17:27:03 +1100
committerAndrew Tridgell <tridge@samba.org>2010-01-08 13:03:04 +1100
commitcd65ce8a18b9ea9a8ce2338bc02c1b3e8ee10225 (patch)
tree6087595ed24ef03c4d1aab243df5baef90d6d786
parentff968e487c9762727d7d2322f3e0fe81b6320cdf (diff)
downloadsamba-cd65ce8a18b9ea9a8ce2338bc02c1b3e8ee10225.tar.gz
samba-cd65ce8a18b9ea9a8ce2338bc02c1b3e8ee10225.tar.bz2
samba-cd65ce8a18b9ea9a8ce2338bc02c1b3e8ee10225.zip
s4-schema: make ldb_val to string comparison safer with nul termination
Pair-Programmed-With: Andrew Bartlett <abartlet@samba.org>
-rw-r--r--source4/dsdb/schema/schema_query.c9
1 files changed, 8 insertions, 1 deletions
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;
}