summaryrefslogtreecommitdiff
path: root/lib/ldb/common
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2011-07-13 13:25:34 +1000
committerAndrew Tridgell <tridge@samba.org>2011-07-13 12:51:05 +0200
commit23b6af10f6ab3852ca28338b8d58342be816f0a2 (patch)
tree2dda4f619b1eb6d6c27342d0bc9d768acdf0f550 /lib/ldb/common
parent2087eb1602d647a7b14523820834231f50dea79d (diff)
downloadsamba-23b6af10f6ab3852ca28338b8d58342be816f0a2.tar.gz
samba-23b6af10f6ab3852ca28338b8d58342be816f0a2.tar.bz2
samba-23b6af10f6ab3852ca28338b8d58342be816f0a2.zip
ldb: added ldb_val_string_cmp()
this should help fix some places where we run past the end of a string Pair-Programmed-With: Andrew Bartlett <abartlet@samba.org>
Diffstat (limited to 'lib/ldb/common')
-rw-r--r--lib/ldb/common/ldb_msg.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/lib/ldb/common/ldb_msg.c b/lib/ldb/common/ldb_msg.c
index 28c414e6b2..1a2bebc983 100644
--- a/lib/ldb/common/ldb_msg.c
+++ b/lib/ldb/common/ldb_msg.c
@@ -1185,3 +1185,15 @@ int ldb_msg_check_string_attribute(const struct ldb_message *msg,
return 0;
}
+
+/*
+ compare a ldb_val to a string
+*/
+int ldb_val_string_cmp(const struct ldb_val *v, const char *str)
+{
+ size_t len = strlen(str);
+ if (len != v->length) {
+ return len - v->length;
+ }
+ return strncmp((const char *)v->data, str, len);
+}