1
0
mirror of https://github.com/samba-team/samba.git synced 2024-12-22 13:34:15 +03:00

CVE-2023-0614 ldb: Add function to remove excess capacity from an ldb message

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

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>

[abartlet@samba.org Adapted to conflict from lack of new
ldb_ascii_toupper() in ldb_private.h]
This commit is contained in:
Joseph Sutton 2023-03-03 17:26:04 +13:00 committed by Jule Anger
parent 891ffeaf99
commit 873d4e465f
2 changed files with 19 additions and 0 deletions

View File

@ -1497,6 +1497,22 @@ void ldb_msg_remove_attr(struct ldb_message *msg, const char *attr)
}
}
/* Reallocate elements to drop any excess capacity. */
void ldb_msg_shrink_to_fit(struct ldb_message *msg)
{
if (msg->num_elements > 0) {
struct ldb_message_element *elements = talloc_realloc(msg,
msg->elements,
struct ldb_message_element,
msg->num_elements);
if (elements != NULL) {
msg->elements = elements;
}
} else {
TALLOC_FREE(msg->elements);
}
}
/*
return a LDAP formatted GeneralizedTime string
*/

View File

@ -317,4 +317,7 @@ int ldb_match_message(struct ldb_context *ldb,
const struct ldb_parse_tree *tree,
enum ldb_scope scope, bool *matched);
/* Reallocate elements to drop any excess capacity. */
void ldb_msg_shrink_to_fit(struct ldb_message *msg);
#endif