diff options
author | Volker Lendecke <vl@samba.org> | 2017-08-21 11:34:45 +0200 |
---|---|---|
committer | Andrew Bartlett <abartlet@samba.org> | 2017-09-16 08:36:17 +0200 |
commit | f08a04c18400371b1951a24c45fcae146bb7ea33 (patch) | |
tree | 101cdb4918fbce1ebf6970e287ea7946e34be74f /libcli | |
parent | 2591e320c07606e4ddfdeacbe46a43d0f4de0f53 (diff) | |
download | samba-f08a04c18400371b1951a24c45fcae146bb7ea33.tar.gz |
netlogon_creds_cli: Simplify netlogon_creds_cli_context_common
printf knows to only print part of a string. No need to talloc_strdup.
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Diffstat (limited to 'libcli')
-rw-r--r-- | libcli/auth/netlogon_creds_cli.c | 19 |
1 files changed, 8 insertions, 11 deletions
diff --git a/libcli/auth/netlogon_creds_cli.c b/libcli/auth/netlogon_creds_cli.c index 751c09f4bdd..b85a7e03b60 100644 --- a/libcli/auth/netlogon_creds_cli.c +++ b/libcli/auth/netlogon_creds_cli.c @@ -113,7 +113,7 @@ static NTSTATUS netlogon_creds_cli_context_common( struct netlogon_creds_cli_context *context = NULL; TALLOC_CTX *frame = talloc_stackframe(); char *_key_name = NULL; - char *server_netbios_name = NULL; + size_t server_netbios_name_len; char *p = NULL; *_context = NULL; @@ -172,22 +172,19 @@ static NTSTATUS netlogon_creds_cli_context_common( * For now we have to deal with * "HOSTNAME" vs. "hostname.example.com". */ - server_netbios_name = talloc_strdup(frame, server_computer); - if (server_netbios_name == NULL) { - TALLOC_FREE(context); - TALLOC_FREE(frame); - return NT_STATUS_NO_MEMORY; - } - p = strchr(server_netbios_name, '.'); + p = strchr(server_computer, '.'); if (p != NULL) { - p[0] = '\0'; + server_netbios_name_len = p-server_computer; + } else { + server_netbios_name_len = strlen(server_computer); } - _key_name = talloc_asprintf(frame, "CLI[%s/%s]/SRV[%s/%s]", + _key_name = talloc_asprintf(frame, "CLI[%s/%s]/SRV[%.*s/%s]", client_computer, client_account, - server_netbios_name, + (int)server_netbios_name_len, + server_computer, server_netbios_domain); if (_key_name == NULL) { TALLOC_FREE(context); |