From: Stefan Metzmacher Date: Wed, 17 May 2017 10:42:04 +0000 (+0200) Subject: s3:libnet_join: remove dead code from libnet_join_connect_ads() X-Git-Tag: samba-4.5.13~75 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=77980addb9c4e713420ed470291a2ebc52d91e76;p=thirdparty%2Fsamba.git s3:libnet_join: remove dead code from libnet_join_connect_ads() username[strlen(username)] is *always* '\0'! BUG: https://bugzilla.samba.org/show_bug.cgi?id=12782 Signed-off-by: Stefan Metzmacher Reviewed-by: Andreas Schneider (cherry picked from commit 5958c6790fbceb39065353c07fe25f74ddf09ef0) --- diff --git a/source3/libnet/libnet_join.c b/source3/libnet/libnet_join.c index 0eee286c779..5089f25967b 100644 --- a/source3/libnet/libnet_join.c +++ b/source3/libnet/libnet_join.c @@ -195,16 +195,11 @@ static ADS_STATUS libnet_join_connect_ads(TALLOC_CTX *mem_ctx, r->in.machine_password == NULL) { return ADS_ERROR_NT(NT_STATUS_INVALID_PARAMETER); } - username = talloc_strdup(mem_ctx, r->in.machine_name); + username = talloc_asprintf(mem_ctx, "%s$", + r->in.machine_name); if (username == NULL) { return ADS_ERROR(LDAP_NO_MEMORY); } - if (username[strlen(username)] != '$') { - username = talloc_asprintf(username, "%s$", username); - if (username == NULL) { - return ADS_ERROR(LDAP_NO_MEMORY); - } - } password = r->in.machine_password; ccname = "MEMORY:libnet_join_machine_creds"; } else {