From aa50aaf8dae9c3c5e6c27ee743cedec1b0524fba Mon Sep 17 00:00:00 2001 From: "Todd C. Miller" Date: Wed, 27 Jan 2021 09:00:49 -0700 Subject: [PATCH] Add missing check for reallocarray() failure. Found by OSS-Fuzz. --- plugins/sudoers/parse_ldif.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/plugins/sudoers/parse_ldif.c b/plugins/sudoers/parse_ldif.c index ce07c1967..53b14a281 100644 --- a/plugins/sudoers/parse_ldif.c +++ b/plugins/sudoers/parse_ldif.c @@ -479,6 +479,8 @@ ldif_to_sudoers(struct sudoers_parse_tree *parse_tree, /* Convert from list of roles to array and sort by order. */ role_array = reallocarray(NULL, numroles + 1, sizeof(*role_array)); + if (role_array == NULL) + sudo_fatalx(U_("%s: %s"), __func__, U_("unable to allocate memory")); for (n = 0; n < numroles; n++) { if ((role = STAILQ_FIRST(roles)) == NULL) break; /* cannot happen */