1
0
mirror of https://github.com/samba-team/samba.git synced 2025-01-11 05:18:09 +03:00
samba-mirror/lib/ldb/include
Joseph Sutton df487eb2d7 CVE-2022-32746 ldb: Add functions for appending to an ldb_message
Currently, there are many places where we use ldb_msg_add_empty() to add
an empty element to a message, and then call ldb_msg_add_value() or
similar to add values to that element. However, this performs an
unnecessary search of the message's elements to locate the new element.
Moreover, if an element with the same attribute name already exists
earlier in the message, the values will be added to that element,
instead of to the intended newly added element.

A similar pattern exists where we add values to a message, and then call
ldb_msg_find_element() to locate that message element and sets its flags
to (e.g.) LDB_FLAG_MOD_REPLACE. This also performs an unnecessary
search, and may locate the wrong message element for setting the flags.

To avoid these problems, add functions for appending a value to a
message, so that a particular value can be added to the end of a message
in a single operation.

For ADD requests, it is important that no two message elements share the
same attribute name, otherwise things will break. (Normally,
ldb_msg_normalize() is called before processing the request to help
ensure this.) Thus, we must be careful not to append an attribute to an
ADD message, unless we are sure (e.g. through ldb_msg_find_element())
that an existing element for that attribute is not present.

These functions will be used in the next commit.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=15009

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
2022-07-27 10:52:36 +00:00
..
dlinklist.h DLIST_REMOVE: clang: Fix dereference of a null pointer warning 2019-06-11 12:10:17 +00:00
ldb_errors.h ldb: make ldb a top level library for Samba 4.0 2011-07-05 17:24:47 +10:00
ldb_handlers.h ldb: Expose ldb_handler_fold() funcion 2011-07-28 15:20:51 +10:00
ldb_module.h CVE-2022-32746 ldb: Add flag to mark message element values as shared 2022-07-27 10:52:36 +00:00
ldb_private.h lib ldb: save a copy of the options on the context 2019-07-02 02:23:09 +00:00
ldb.h CVE-2022-32746 ldb: Add functions for appending to an ldb_message 2022-07-27 10:52:36 +00:00