mirror of
https://github.com/samba-team/samba.git
synced 2025-01-10 01:18:15 +03:00
s3: Use asprintf where appropriate
This commit is contained in:
parent
7ba5855a73
commit
54f0da368f
@ -118,7 +118,6 @@ static const SMB_Ctrls smb_args[SMB_CTRLS_] = {
|
|||||||
* to authenticate themself.
|
* to authenticate themself.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define FAIL_PREFIX "-SMB-FAIL-"
|
|
||||||
#define SMB_MAX_RETRIES 3
|
#define SMB_MAX_RETRIES 3
|
||||||
|
|
||||||
struct _pam_failed_auth {
|
struct _pam_failed_auth {
|
||||||
|
@ -176,17 +176,12 @@ int pam_sm_chauthtok(pam_handle_t *pamh, int flags,
|
|||||||
if (getuid() != 0 && !(flags & PAM_CHANGE_EXPIRED_AUTHTOK)) {
|
if (getuid() != 0 && !(flags & PAM_CHANGE_EXPIRED_AUTHTOK)) {
|
||||||
|
|
||||||
/* tell user what is happening */
|
/* tell user what is happening */
|
||||||
#define greeting "Changing password for "
|
if (asprintf(&Announce, "Changing password for %s", user) == -1) {
|
||||||
Announce = SMB_MALLOC_ARRAY(char, sizeof(greeting)+strlen(user));
|
_log_err(pamh, LOG_CRIT, "password: out of memory");
|
||||||
if (Announce == NULL) {
|
TALLOC_FREE(sampass);
|
||||||
_log_err(pamh, LOG_CRIT, "password: out of memory");
|
CatchSignal(SIGPIPE, oldsig_handler);
|
||||||
TALLOC_FREE(sampass);
|
return PAM_BUF_ERR;
|
||||||
CatchSignal(SIGPIPE, oldsig_handler);
|
}
|
||||||
return PAM_BUF_ERR;
|
|
||||||
}
|
|
||||||
strncpy( Announce, greeting, sizeof(greeting) );
|
|
||||||
strncpy( Announce+sizeof(greeting)-1, user, strlen(user)+1 );
|
|
||||||
#undef greeting
|
|
||||||
|
|
||||||
set( SMB__OLD_PASSWD, ctrl );
|
set( SMB__OLD_PASSWD, ctrl );
|
||||||
retval = _smb_read_password( pamh, ctrl, Announce, "Current SMB password: ",
|
retval = _smb_read_password( pamh, ctrl, Announce, "Current SMB password: ",
|
||||||
|
@ -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 (asprintf(&data_name, "-SMB-FAIL- %s", name) == -1) {
|
||||||
if (data_name == NULL) {
|
|
||||||
_log_err(pamh, LOG_CRIT, "no memory for data-name" );
|
_log_err(pamh, LOG_CRIT, "no memory for data-name" );
|
||||||
return PAM_AUTH_ERR;
|
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
|
* The password we were given wasn't an encrypted password, or it
|
||||||
|
Loading…
Reference in New Issue
Block a user