The Samba-Bugzilla – Attachment 17182 Details for
Bug 14993
authsam_make_user_info_dc() steals memory from its struct ldb_message *msg argument
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch for v4-15-test
bfixes-tmp415.txt (text/plain), 2.25 KB, created by
Stefan Metzmacher
on 2022-03-02 08:12:12 UTC
(
hide
)
Description:
Patch for v4-15-test
Filename:
MIME Type:
Creator:
Stefan Metzmacher
Created:
2022-03-02 08:12:12 UTC
Size:
2.25 KB
patch
obsolete
>From e4801b62bc18359f71bc34488873fa85a89ed8cd Mon Sep 17 00:00:00 2001 >From: Stefan Metzmacher <metze@samba.org> >Date: Fri, 25 Feb 2022 07:40:17 +0100 >Subject: [PATCH] s4:sam: Don't use talloc_steal for msg attributes in > authsam_make_user_info_dc() > >This is most likely not a problem for the current callers, >but that it is unexpected and will likely cause problems with future >changes. > >BUG: https://bugzilla.samba.org/show_bug.cgi?id=14993 >BUG: https://bugzilla.samba.org/show_bug.cgi?id=14995 > >Signed-off-by: Stefan Metzmacher <metze@samba.org> >Reviewed-by: Andrew Bartlett <abartlet@samba.org> >(cherry picked from commit f6fe86924c2ca756083d3628d5dbace0b12d06b0) >--- > source4/auth/sam.c | 19 ++++++++++++++----- > 1 file changed, 14 insertions(+), 5 deletions(-) > >diff --git a/source4/auth/sam.c b/source4/auth/sam.c >index 93b41be3b210..8b233bab3ad8 100644 >--- a/source4/auth/sam.c >+++ b/source4/auth/sam.c >@@ -454,12 +454,15 @@ _PUBLIC_ NTSTATUS authsam_make_user_info_dc(TALLOC_CTX *mem_ctx, > user_info_dc->info = info = talloc_zero(user_info_dc, struct auth_user_info); > NT_STATUS_HAVE_NO_MEMORY(user_info_dc->info); > >- info->account_name = talloc_steal(info, >- ldb_msg_find_attr_as_string(msg, "sAMAccountName", NULL)); >+ str = ldb_msg_find_attr_as_string(msg, "sAMAccountName", NULL); >+ info->account_name = talloc_strdup(info, str); >+ if (info->account_name == NULL) { >+ TALLOC_FREE(user_info_dc); >+ return NT_STATUS_NO_MEMORY; >+ } > >- info->user_principal_name = talloc_steal(info, >- ldb_msg_find_attr_as_string(msg, "userPrincipalName", NULL)); >- if (info->user_principal_name == NULL && dns_domain_name != NULL) { >+ str = ldb_msg_find_attr_as_string(msg, "userPrincipalName", NULL); >+ if (str == NULL && dns_domain_name != NULL) { > info->user_principal_name = talloc_asprintf(info, "%s@%s", > info->account_name, > dns_domain_name); >@@ -468,6 +471,12 @@ _PUBLIC_ NTSTATUS authsam_make_user_info_dc(TALLOC_CTX *mem_ctx, > return NT_STATUS_NO_MEMORY; > } > info->user_principal_constructed = true; >+ } else if (str != NULL) { >+ info->user_principal_name = talloc_strdup(info, str); >+ if (info->user_principal_name == NULL) { >+ TALLOC_FREE(user_info_dc); >+ return NT_STATUS_NO_MEMORY; >+ } > } > > info->domain_name = talloc_strdup(info, domain_name); >-- >2.25.1 >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Flags:
abartlet
:
review+
Actions:
View
Attachments on
bug 14993
: 17182 |
17183