diff options
author | Andreas Schneider <asn@samba.org> | 2019-08-21 12:22:32 +0200 |
---|---|---|
committer | Stefan Metzmacher <metze@samba.org> | 2019-10-16 12:15:53 +0000 |
commit | 60c5d1d3de6c8a44f716349805a8ac0dc935d97d (patch) | |
tree | 97e6e3882b64c8bb8f4891eb08d2921c12277b70 | |
parent | ddd4a6af621799c4d7e38373733ec1bb1c168a9e (diff) | |
download | samba-60c5d1d3de6c8a44f716349805a8ac0dc935d97d.tar.gz |
s3:libads: Use a talloc_asprintf in ads_find_machine_acct()
Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Alexander Bokovoy <ab@samba.org>
(cherry picked from commit 35f3e4aed1f1c2ba1c8dc50921f238937f343357)
-rw-r--r-- | source3/libads/ldap.c | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/source3/libads/ldap.c b/source3/libads/ldap.c index e492d0688a5..3bc9a2a06aa 100644 --- a/source3/libads/ldap.c +++ b/source3/libads/ldap.c @@ -1367,18 +1367,22 @@ char *ads_parent_dn(const char *dn) ADS_STATUS status; char *expr; const char *attrs[] = {"*", "msDS-SupportedEncryptionTypes", "nTSecurityDescriptor", NULL}; + TALLOC_CTX *frame = talloc_stackframe(); *res = NULL; /* the easiest way to find a machine account anywhere in the tree is to look for hostname$ */ - if (asprintf(&expr, "(samAccountName=%s$)", machine) == -1) { - DEBUG(1, ("asprintf failed!\n")); - return ADS_ERROR_NT(NT_STATUS_NO_MEMORY); + expr = talloc_asprintf(frame, "(samAccountName=%s$)", machine); + if (expr == NULL) { + status = ADS_ERROR_NT(NT_STATUS_NO_MEMORY); + goto done; } status = ads_search(ads, res, expr, attrs); - SAFE_FREE(expr); + +done: + TALLOC_FREE(frame); return status; } |