diff mbox series

[2/3] libsepol: avoid integer overflow in add_i_to_a()

Message ID 20231211144827.121636-2-cgzones@googlemail.com (mailing list archive)
State Accepted
Commit a55cd37461f2
Headers show
Series [1/3] libsepol: constify tokenized input | expand

Commit Message

Christian Göttsche Dec. 11, 2023, 2:48 p.m. UTC
Signed-off-by: Christian Göttsche <cgzones@googlemail.com>
---
 libsepol/src/util.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/libsepol/src/util.c b/libsepol/src/util.c
index 571f6c93..4a6f7d11 100644
--- a/libsepol/src/util.c
+++ b/libsepol/src/util.c
@@ -44,7 +44,7 @@  int add_i_to_a(uint32_t i, uint32_t * cnt, uint32_t ** a)
 {
 	uint32_t *new;
 
-	if (cnt == NULL || a == NULL)
+	if (cnt == NULL || *cnt == UINT32_MAX || a == NULL)
 		return -1;
 
 	/* FIX ME: This is not very elegant! We use an array that we