From 0f163eb61113424e55887a9d0f2a7a89b109c4d0 Mon Sep 17 00:00:00 2001 From: Matthias Dieter Wallnöfer Date: Thu, 16 Sep 2010 18:08:56 +0200 Subject: ldb:ldb_msg_add_linearized_dn - handle NULL DNs Don't let the routine crash Signed-off-by: Andrew Bartlett --- source4/lib/ldb/common/ldb_msg.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'source4/lib') diff --git a/source4/lib/ldb/common/ldb_msg.c b/source4/lib/ldb/common/ldb_msg.c index 5ca3dbb91c..dfd86c6d3a 100644 --- a/source4/lib/ldb/common/ldb_msg.c +++ b/source4/lib/ldb/common/ldb_msg.c @@ -307,8 +307,14 @@ int ldb_msg_add_steal_string(struct ldb_message *msg, int ldb_msg_add_linearized_dn(struct ldb_message *msg, const char *attr_name, struct ldb_dn *dn) { - return ldb_msg_add_steal_string(msg, attr_name, - ldb_dn_alloc_linearized(msg, dn)); + char *str = ldb_dn_alloc_linearized(msg, dn); + + if (str == NULL) { + /* we don't want to have unknown DNs added */ + return LDB_ERR_OPERATIONS_ERROR; + } + + return ldb_msg_add_steal_string(msg, attr_name, str); } /* -- cgit