From 8b1b708e5f7ad8bb9c1c860fe60c5f104e0bf036 Mon Sep 17 00:00:00 2001 From: Cheyenne Wills Date: Fri, 6 Aug 2021 11:55:55 -0600 Subject: [PATCH] libacl: Fix problems found by static analysis Several static analysis tools have identified various problems: - missing checks to ensure *alloc was successful (infer) To resolve the above problems: - add checks to ensure *alloc was successful before using the memory This commit is a reorganization of commits developed by Pat Riehecky, who ran the static analysis tools and developed the fixes. Change-Id: I48e053e73131c3f86928a4658dbc69e56abd2b20 Reviewed-on: https://gerrit.openafs.org/14683 Reviewed-by: Andrew Deason Reviewed-by: Cheyenne Wills Tested-by: BuildBot Reviewed-by: Michael Meffie --- src/libacl/aclprocs.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/libacl/aclprocs.c b/src/libacl/aclprocs.c index fbdfaa6f9c..56af0d8184 100644 --- a/src/libacl/aclprocs.c +++ b/src/libacl/aclprocs.c @@ -186,6 +186,9 @@ acl_Externalize_pr(int (*func)(idlist *ids, namelist *names), struct acl_accessL acl_NewExternalACL(acl->total, elist); nextc = *elist; lids.idlist_val = calloc(ACL_MAXENTRIES, sizeof(afs_int32)); + if (lids.idlist_val == NULL) { + return ENOMEM; + } lids.idlist_len = acl->total; lnames.namelist_len = 0; lnames.namelist_val = (prname *) 0;