ldb:ldb_msg_add_linearized_dn - handle NULL DNs
authorMatthias Dieter Wallnöfer <mdw@samba.org>
Thu, 16 Sep 2010 16:08:56 +0000 (18:08 +0200)
committerAndrew Bartlett <abartlet@samba.org>
Thu, 23 Sep 2010 23:25:41 +0000 (09:25 +1000)
Don't let the routine crash

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
source4/lib/ldb/common/ldb_msg.c

index 5ca3dbb91c4f7321bfcbe98d6e576c7e96d1cda0..dfd86c6d3a894c255b3f0a5f308181cf78e7f8f8 100644 (file)
@@ -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);
 }
 
 /*