Skip to contentSkip to conversation

libselinux: Fix selabel_lookup() for the root dir.

PATCH Superseded Chris PeBenito 2 participants 2 messages Sep 11, 2020 SELinux security module

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

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

9e4480b introduced a change for removing trailing slashes from selabel_lookup() for files contexts. However, it turns the root directory lookup "/" into an empty string.

---
 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 v1 1/1
#1 lore raw
Quoted 2 lines · Chris PeBenito

9e4480b introduced a change for removing trailing slashes from

For the kernel at least we require the style:
commit <12+ chars of sha1> ("commit subject line")
to ensure that the reference is unambiguous and the reader gets at least a partial description even without going off to look at it separately.

Quoted 4 lines

selabel_lookup() for files contexts. However, it turns the root directory lookup "/" into an empty string.

Quoted 20 lines
---
 libselinux/src/label_file.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
libselinux/src/label_file.c +1 -2
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);
--

2.26.2