Use calloc() instead of malloc(n * s) followed by memset().

From Jean-Philippe Ouellet.
This commit is contained in:
Todd C. Miller
2014-04-22 16:06:04 -06:00
parent 62a278183b
commit e8bb08cc46
2 changed files with 2 additions and 2 deletions

View File

@@ -99,6 +99,7 @@ you believe you should be listed, please send a note to sudo@sudo.ws.
Nieusma, Jeff
Nikitser, Peter A.
Nussel, Ludwig
Ouellet, Jean-Philippe
Paquet, Eric
Paradis, Chantal
Percival, Ted

View File

@@ -315,9 +315,8 @@ converse(int num_msg, PAM_CONST struct pam_message **msg,
int ret = PAM_AUTH_ERR;
debug_decl(converse, SUDO_DEBUG_AUTH)
if ((*response = malloc(num_msg * sizeof(struct pam_response))) == NULL)
if ((*response = calloc(num_msg, sizeof(struct pam_response))) == NULL)
debug_return_int(PAM_SYSTEM_ERR);
memset(*response, 0, num_msg * sizeof(struct pam_response));
for (pr = *response, pm = *msg, n = num_msg; n--; pr++, pm++) {
type = SUDO_CONV_PROMPT_ECHO_OFF;