From 69e62f316e356e68e6edb7dbb4da70943a0d7896 Mon Sep 17 00:00:00 2001 From: "Todd C. Miller" Date: Wed, 20 May 2015 10:59:03 -0600 Subject: [PATCH] Use reallocarray() instead of sudo_emallocarray() and return an error on allocation failure. --- plugins/sudoers/auth/sia.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/plugins/sudoers/auth/sia.c b/plugins/sudoers/auth/sia.c index c8d2ff036..86c1aeefa 100644 --- a/plugins/sudoers/auth/sia.c +++ b/plugins/sudoers/auth/sia.c @@ -114,7 +114,11 @@ sudo_sia_setup(struct passwd *pw, char **promptp, sudo_auth *auth) /* Rebuild argv for sia_ses_init() */ sudo_argc = NewArgc + 1; - sudo_argv = sudo_emallocarray(sudo_argc + 1, sizeof(char *)); + sudo_argv = reallocarray(NULL, sudo_argc + 1, sizeof(char *)); + if (sudo_argv == NULL) { + log_warning(0, N_("unable to allocate memory")); + debug_return_int(AUTH_FATAL); + } sudo_argv[0] = "sudo"; for (i = 0; i < NewArgc; i++) sudo_argv[i + 1] = NewArgv[i]; @@ -152,7 +156,7 @@ sudo_sia_cleanup(struct passwd *pw, sudo_auth *auth) debug_decl(sudo_sia_cleanup, SUDOERS_DEBUG_AUTH) (void) sia_ses_release(&siah); - sudo_efree(sudo_argv); + free(sudo_argv); debug_return_int(AUTH_SUCCESS); } -- 2.40.0