]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
ldb: Account for ‘name’ possibly being NULL
authorJoseph Sutton <josephsutton@catalyst.net.nz>
Mon, 31 Jul 2023 21:34:34 +0000 (09:34 +1200)
committerAndrew Bartlett <abartlet@samba.org>
Tue, 8 Aug 2023 04:39:37 +0000 (04:39 +0000)
Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
lib/ldb/common/ldb_msg.c
lib/ldb/pyldb.c

index dbc7e71b7b6d115560014beb7608c20511a58189..8ffbced940a9e1e5693f0d807cd74352c4e92ffd 100644 (file)
@@ -1169,8 +1169,10 @@ struct ldb_message *ldb_msg_copy(TALLOC_CTX *mem_ctx,
        for (i=0;i<msg2->num_elements;i++) {
                struct ldb_message_element *el = &msg2->elements[i];
                struct ldb_val *values = el->values;
-               el->name = talloc_strdup(msg2->elements, el->name);
-               if (el->name == NULL) goto failed;
+               if (el->name != NULL) {
+                       el->name = talloc_strdup(msg2->elements, el->name);
+                       if (el->name == NULL) goto failed;
+               }
                el->values = talloc_array(msg2->elements, struct ldb_val, el->num_values);
                if (el->values == NULL) goto failed;
                for (j=0;j<el->num_values;j++) {
index 798db2aff017ab4cdc31aaa4046a7729db2a9110..38a4f3d29ced3b694d75ac4a5c84c27e12f4c165 100644 (file)
@@ -3440,7 +3440,9 @@ static PyObject *py_ldb_msg_element_new(PyTypeObject *type, PyObject *args, PyOb
        }
 
        el->flags = flags;
-       el->name = talloc_strdup(el, name);
+       if (name != NULL) {
+               el->name = talloc_strdup(el, name);
+       }
 
        ret = PyObject_New(PyLdbMessageElementObject, type);
        if (ret == NULL) {