diff options
author | Volker Lendecke <vl@samba.org> | 2010-09-22 14:10:03 +0200 |
---|---|---|
committer | Volker Lendecke <vl@samba.org> | 2010-09-22 15:42:28 -0700 |
commit | 54f0da368f35ce7d7fd4b093b865ffea284d826b (patch) | |
tree | cfb020a9e50836c4fc4186983a959412d0930052 /source3/pam_smbpass | |
parent | 7ba5855a734037cf7308007b953ce0a92b050173 (diff) | |
download | samba-54f0da368f35ce7d7fd4b093b865ffea284d826b.tar.gz samba-54f0da368f35ce7d7fd4b093b865ffea284d826b.tar.bz2 samba-54f0da368f35ce7d7fd4b093b865ffea284d826b.zip |
s3: Use asprintf where appropriate
Diffstat (limited to 'source3/pam_smbpass')
-rw-r--r-- | source3/pam_smbpass/general.h | 1 | ||||
-rw-r--r-- | source3/pam_smbpass/pam_smb_passwd.c | 17 | ||||
-rw-r--r-- | source3/pam_smbpass/support.c | 5 |
3 files changed, 7 insertions, 16 deletions
diff --git a/source3/pam_smbpass/general.h b/source3/pam_smbpass/general.h index 4607620c29..f6b3e672ae 100644 --- a/source3/pam_smbpass/general.h +++ b/source3/pam_smbpass/general.h @@ -118,7 +118,6 @@ static const SMB_Ctrls smb_args[SMB_CTRLS_] = { * to authenticate themself. */ -#define FAIL_PREFIX "-SMB-FAIL-" #define SMB_MAX_RETRIES 3 struct _pam_failed_auth { diff --git a/source3/pam_smbpass/pam_smb_passwd.c b/source3/pam_smbpass/pam_smb_passwd.c index 473a55e065..8fc2cf3e14 100644 --- a/source3/pam_smbpass/pam_smb_passwd.c +++ b/source3/pam_smbpass/pam_smb_passwd.c @@ -176,17 +176,12 @@ int pam_sm_chauthtok(pam_handle_t *pamh, int flags, if (getuid() != 0 && !(flags & PAM_CHANGE_EXPIRED_AUTHTOK)) { /* tell user what is happening */ -#define greeting "Changing password for " - Announce = SMB_MALLOC_ARRAY(char, sizeof(greeting)+strlen(user)); - if (Announce == NULL) { - _log_err(pamh, LOG_CRIT, "password: out of memory"); - TALLOC_FREE(sampass); - CatchSignal(SIGPIPE, oldsig_handler); - return PAM_BUF_ERR; - } - strncpy( Announce, greeting, sizeof(greeting) ); - strncpy( Announce+sizeof(greeting)-1, user, strlen(user)+1 ); -#undef greeting + if (asprintf(&Announce, "Changing password for %s", user) == -1) { + _log_err(pamh, LOG_CRIT, "password: out of memory"); + TALLOC_FREE(sampass); + CatchSignal(SIGPIPE, oldsig_handler); + return PAM_BUF_ERR; + } set( SMB__OLD_PASSWD, ctrl ); retval = _smb_read_password( pamh, ctrl, Announce, "Current SMB password: ", diff --git a/source3/pam_smbpass/support.c b/source3/pam_smbpass/support.c index 4215c72991..79f92a8758 100644 --- a/source3/pam_smbpass/support.c +++ b/source3/pam_smbpass/support.c @@ -379,13 +379,10 @@ int _smb_verify_password( pam_handle_t * pamh, struct samu *sampass, } } - data_name = SMB_MALLOC_ARRAY(char, sizeof(FAIL_PREFIX) + strlen( name )); - if (data_name == NULL) { + if (asprintf(&data_name, "-SMB-FAIL- %s", name) == -1) { _log_err(pamh, LOG_CRIT, "no memory for data-name" ); return PAM_AUTH_ERR; } - strncpy( data_name, FAIL_PREFIX, sizeof(FAIL_PREFIX) ); - strncpy( data_name + sizeof(FAIL_PREFIX) - 1, name, strlen( name ) + 1 ); /* * The password we were given wasn't an encrypted password, or it |