libselinux: add check for calloc in check_booleans
PATCH 1/1 libselinux: add check for calloc in check_booleans
Check the return value of calloc() to avoid null pointer reference.
Signed-off-by Huaxin Lu <[email protected]>
--- libselinux/src/audit2why.c | 6 ++++++ 1 file changed, 6 insertions(+)
libselinux/src/audit2why.c +6 -0
@@ -149,6 +149,12 @@ static int check_booleans(struct boolean_t **bools)if (fcnt >0 ) { *bools =calloc (sizeof (struct boolean_t ), fcnt +1 ); +if (!*bools) { +PyErr_SetString ( PyExc_MemoryError,"Out of memory\n" ); +free (foundlist); +return 0 ; + } +struct boolean_t *b = *bools;for (i =0 ; i < fcnt; i++) {int ctr = foundlist[i];
Signature · 1 line
2.33.0
Quoted 12 lines · Huaxin Lu
Check the return value of
calloc()to avoid null pointer reference.Signed-off-by Huaxin Lu <[email protected]>--- libselinux/src/audit2why.c | 6 ++++++ 1 file changed, 6 insertions(+)libselinux/src/audit2why.c +0
-0
libselinux/src/audit2why.c static int check_booleans(struct boolean_t **bools) · line 157
Quoted 9 lines
libselinux/src/audit2why.c +6
-0@@ -149,6 +149,12 @@ static int check_booleans(struct boolean_t **bools)if (fcnt >0 ) { *bools =calloc (sizeof (struct boolean_t ), fcnt +1 ); +if (!*bools) { +PyErr_SetString ( PyExc_MemoryError,"Out of memory\n" ); +free (foundlist); +return 0 ; + } +
There's a trailing whitespace, but it's not necessary to resend the patch.
Acked-by Petr Lautrbach <[email protected]>
Quoted 5 lines
libselinux/src/audit2why.c +0
-0struct boolean_t *b = *bools;for (i =0 ; i < fcnt; i++) {int ctr = foundlist[i];Signature · 1 line
2.33.0
Petr Lautrbach
AppliedQuoted 26 lines · Petr Lautrbach
Quoted 12 lines · Huaxin Lu
Check the return value of
calloc()to avoid null pointer reference.Signed-off-by Huaxin Lu <[email protected]>--- libselinux/src/audit2why.c | 6 ++++++ 1 file changed, 6 insertions(+)libselinux/src/audit2why.c +0
-0libselinux/src/audit2why.c static int check_booleans(struct boolean_t **bools) · line 157
Quoted 9 lines
libselinux/src/audit2why.c +6
-0@@ -149,6 +149,12 @@ static int check_booleans(struct boolean_t **bools)if (fcnt >0 ) { *bools =calloc (sizeof (struct boolean_t ), fcnt +1 ); +if (!*bools) { +PyErr_SetString ( PyExc_MemoryError,"Out of memory\n" ); +free (foundlist); +return 0 ; + } +There's a trailing whitespace, but it's not necessary to resend the patch.
Quoted 2 lines
Acked-by Petr Lautrbach <[email protected]>
merged, thanks
Quoted 5 lines
Quoted 5 lines
libselinux/src/audit2why.c +0
-0struct boolean_t *b = *bools;for (i =0 ; i < fcnt; i++) {int ctr = foundlist[i];Signature · 1 line
2.33.0