Skip to contentSkip to conversation

libselinux: label: ensure specfile_list is NULL-terminated

PATCH In review Stephen Smalley 2 participants 3 messages Jun 4 – Jun 5 SELinux security module

lore
Share & tools
lore

Stephen Smalley

author maintainer
#0 lore raw

PATCH 1/1 libselinux: label: ensure specfile_list is NULL-terminated

selabel_digest_fini() walks the specfile_list until it reaches a NULL; we therefore need to ensure that there is always an extra NULL slot at the end.

---
 libselinux/src/label.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
libselinux/src/label.c +1 -1
index dcbd60ab..1ccd1abe 100644
@@ -70,7 +70,7 @@ selabel_is_digest_set(const struct selinux_opt *opts, unsigned n)
 				goto err;
 
 			digest->specfile_list =
-				calloc(DIGEST_FILES_MAX, sizeof(char *));
+				calloc(DIGEST_FILES_MAX + 1, sizeof(char *));
 			if (!digest->specfile_list)
 				goto err;
 
Signature · 1 line
2.54.0
Acked-by on v1 1/1
#1 lore raw
Quoted 6 lines · Stephen Smalley

selabel_digest_fini() walks the specfile_list until it reaches a NULL; we therefore need to ensure that there is always an extra NULL slot at the end.

Quoted 20 lines
---
 libselinux/src/label.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
libselinux/src/label.c +1 -2
index dcbd60ab..1ccd1abe 100644
@@ -70,7 +70,7 @@ selabel_is_digest_set(const struct selinux_opt *opts, unsigned n)
                                goto err;
 
                        digest->specfile_list =
-                               calloc(DIGEST_FILES_MAX, sizeof(char *));
+                               calloc(DIGEST_FILES_MAX + 1, sizeof(char *));
                        if (!digest->specfile_list)
                                goto err;
 
--

2.54.0

author maintainer
#2 lore raw
Quoted 11 lines · James Carter
Quoted 6 lines · Stephen Smalley

selabel_digest_fini() walks the specfile_list until it reaches a NULL; we therefore need to ensure that there is always an extra NULL slot at the end.

Merged.

Quoted 21 lines
Quoted 21 lines
---
 libselinux/src/label.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
libselinux/src/label.c +1 -2
index dcbd60ab..1ccd1abe 100644
@@ -70,7 +70,7 @@ selabel_is_digest_set(const struct selinux_opt *opts, unsigned n)
                                goto err;
 
                        digest->specfile_list =
-                               calloc(DIGEST_FILES_MAX, sizeof(char *));
+                               calloc(DIGEST_FILES_MAX + 1, sizeof(char *));
                        if (!digest->specfile_list)
                                goto err;
 
--

2.54.0