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 <adeason@sinenomine.net>
Reviewed-by: Cheyenne Wills <cwills@sinenomine.net>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>
This commit is contained in:
Cheyenne Wills 2021-08-06 11:55:55 -06:00 committed by Michael Meffie
parent 56d5ee3800
commit 8b1b708e5f

View File

@ -186,6 +186,9 @@ acl_Externalize_pr(int (*func)(idlist *ids, namelist *names), struct acl_accessL
acl_NewExternalACL(acl->total, elist); acl_NewExternalACL(acl->total, elist);
nextc = *elist; nextc = *elist;
lids.idlist_val = calloc(ACL_MAXENTRIES, sizeof(afs_int32)); lids.idlist_val = calloc(ACL_MAXENTRIES, sizeof(afs_int32));
if (lids.idlist_val == NULL) {
return ENOMEM;
}
lids.idlist_len = acl->total; lids.idlist_len = acl->total;
lnames.namelist_len = 0; lnames.namelist_len = 0;
lnames.namelist_val = (prname *) 0; lnames.namelist_val = (prname *) 0;