s3:libnet_join: remove dead code from libnet_join_connect_ads()
authorStefan Metzmacher <metze@samba.org>
Wed, 17 May 2017 10:42:04 +0000 (12:42 +0200)
committerStefan Metzmacher <metze@samba.org>
Tue, 27 Jun 2017 14:57:43 +0000 (16:57 +0200)
username[strlen(username)] is *always* '\0'!

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

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
source3/libnet/libnet_join.c

index 4d00ef6..e33c383 100644 (file)
@@ -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 {