|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [PATCH] loadpolicy: Verifies memory allocation during policy loading
From: Yunseong Kim <yskelg@xxxxxxxxx>
memory allocation failure handling in the loadpolicy module.
Signed-off-by: Yunseong Kim <yskelg@xxxxxxxxx>
---
tools/flask/utils/loadpolicy.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/tools/flask/utils/loadpolicy.c b/tools/flask/utils/loadpolicy.c
index 76710a256c..7f6bab4dcd 100644
--- a/tools/flask/utils/loadpolicy.c
+++ b/tools/flask/utils/loadpolicy.c
@@ -58,6 +58,11 @@ int main (int argCnt, const char *args[])
}
polMemCp = malloc(info.st_size);
+ if (!polMemCp) {
+ fprintf(stderr, "Error occurred allocating %ld bytes\n", info.st_size);
+ ret = -ENOMEM;
+ goto cleanup;
+ }
#ifdef USE_MMAP
polMem = mmap(NULL, info.st_size, PROT_READ, MAP_SHARED, polFd, 0);
--
2.34.1
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |