summaryrefslogtreecommitdiff
path: root/source4/lib/ldb/common
diff options
context:
space:
mode:
authorAndrew Bartlett <abartlet@samba.org>2006-02-22 09:28:58 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 13:51:59 -0500
commit98c0767677156ff31791bd93f473ac11f856c75a (patch)
tree565141973847ef6633f2159bc25d22975a782228 /source4/lib/ldb/common
parentd590dea10b3abf93fcc8138189291e8b66bae7d7 (diff)
downloadsamba-98c0767677156ff31791bd93f473ac11f856c75a.tar.gz
samba-98c0767677156ff31791bd93f473ac11f856c75a.tar.bz2
samba-98c0767677156ff31791bd93f473ac11f856c75a.zip
r13616: Add new ldb functions: ldb_msg_add_steal_string() and
ldb_msg_add_steal_value(). These try to maintain the talloc heirachy, which must be correct otherwise talloc_steal operations of entire attribute lists fails. This fixes the currentTime value, found by using Microsoft's dcdiag tool (before this commit, it pointed to invalid memory, due to the changes in -r 13606) Andrew Bartlett (This used to be commit 424df1bb369fddcfd358cf26dd0da9d3851d181e)
Diffstat (limited to 'source4/lib/ldb/common')
-rw-r--r--source4/lib/ldb/common/ldb_msg.c32
1 files changed, 32 insertions, 0 deletions
diff --git a/source4/lib/ldb/common/ldb_msg.c b/source4/lib/ldb/common/ldb_msg.c
index 497d2cb0d5..8c59518296 100644
--- a/source4/lib/ldb/common/ldb_msg.c
+++ b/source4/lib/ldb/common/ldb_msg.c
@@ -199,6 +199,24 @@ int ldb_msg_add_value(struct ldb_message *msg,
/*
+ add a value to a message, stealing it into the 'right' place
+*/
+int ldb_msg_add_steal_value(struct ldb_message *msg,
+ const char *attr_name,
+ struct ldb_val *val)
+{
+ int ret;
+ ret = ldb_msg_add_value(msg, attr_name, val);
+ if (ret == LDB_SUCCESS) {
+ struct ldb_message_element *el;
+ el = ldb_msg_find_element(msg, attr_name);
+ talloc_steal(el->values, val->data);
+ }
+ return ret;
+}
+
+
+/*
add a string element to a message
*/
int ldb_msg_add_string(struct ldb_message *msg,
@@ -213,6 +231,20 @@ int ldb_msg_add_string(struct ldb_message *msg,
}
/*
+ add a string element to a message, stealing it into the 'right' place
+*/
+int ldb_msg_add_steal_string(struct ldb_message *msg,
+ const char *attr_name, char *str)
+{
+ struct ldb_val val;
+
+ val.data = (uint8_t *)str;
+ val.length = strlen(str);
+
+ return ldb_msg_add_steal_value(msg, attr_name, &val);
+}
+
+/*
add a printf formatted element to a message
*/
int ldb_msg_add_fmt(struct ldb_message *msg,