Skip to contentSkip to conversation

libselinux: Fix selabel_lookup() for the root dir.

PATCH Applied Chris PeBenito 2 participants 3 messages Sep 11, 2020 – Sep 16, 2020 SELinux security module

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 libselinux: Fix selabel_lookup() for the root dir.

9e4480b921bb ("Remove trailing slash on selabel_file lookups.") introduced a bug which turns the root directory lookup "/" into an empty string.

v2: Fix commit message

---
 libselinux/src/label_file.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
libselinux/src/label_file.c +1 -1
index 6eeeea68..726394ca 100644
@@ -902,7 +902,7 @@ static const struct spec **lookup_all(struct selabel_handle *rec,
 		goto finish;
 	}
 
-	if (key[len - 1] == '/') {
+	if (len > 1 && key[len - 1] == '/') {
 		/* reuse clean_key from above if available */
 		if (!clean_key) {
 			clean_key = (char *) malloc(len);
Signature · 1 line
2.26.2
maintainer Acked-by on v2 1/1
#1 lore raw
Quoted 3 lines · Chris PeBenito

9e4480b921bb ("Remove trailing slash on selabel_file lookups.") introduced a bug which turns the root directory lookup "/" into an empty string.

Thanks.

Quoted 1 line

v2: Fix commit message

This should go after the --- so that it doesn't get included in the commit message since only the final version gets committed. But don't worry about re-posting just for that; I can just amend it before merging if I remember or if not no big deal.

Quoted 1 line
maintainer Applied
#2 lore raw
Quoted 11 lines · Stephen Smalley
Quoted 3 lines · Chris PeBenito

9e4480b921bb ("Remove trailing slash on selabel_file lookups.") introduced a bug which turns the root directory lookup "/" into an empty string.

Thanks.

Quoted 1 line

v2: Fix commit message

Quoted 8 lines

This should go after the --- so that it doesn't get included in the commit message since only the final version gets committed. But don't worry about re-posting just for that; I can just amend it before merging if I remember or if not no big deal.

Quoted 1 line

Applied.