diff mbox series

[v2,1/1] libselinux: Fix selabel_lookup() for the root dir.

Message ID 20200911195614.429223-1-chpebeni@linux.microsoft.com (mailing list archive)
State Accepted
Headers show
Series [v2,1/1] libselinux: Fix selabel_lookup() for the root dir. | expand

Commit Message

Chris PeBenito Sept. 11, 2020, 7:56 p.m. UTC
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

Signed-off-by: Chris PeBenito <chpebeni@linux.microsoft.com>
---
 libselinux/src/label_file.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Stephen Smalley Sept. 11, 2020, 8:18 p.m. UTC | #1
On Fri, Sep 11, 2020 at 3:57 PM Chris PeBenito
<chpebeni@linux.microsoft.com> wrote:
>
> 9e4480b921bb ("Remove trailing slash on selabel_file lookups.") introduced
> a bug which turns the root directory lookup "/" into an empty string.

Thanks.

> 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.

> Signed-off-by: Chris PeBenito <chpebeni@linux.microsoft.com>

Acked-by: Stephen Smalley <stephen.smalley.work@gmail.com>
Stephen Smalley Sept. 15, 2020, 1:23 p.m. UTC | #2
On Fri, Sep 11, 2020 at 4:18 PM Stephen Smalley
<stephen.smalley.work@gmail.com> wrote:
>
> On Fri, Sep 11, 2020 at 3:57 PM Chris PeBenito
> <chpebeni@linux.microsoft.com> wrote:
> >
> > 9e4480b921bb ("Remove trailing slash on selabel_file lookups.") introduced
> > a bug which turns the root directory lookup "/" into an empty string.
>
> Thanks.
>
> > 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.
>
> > Signed-off-by: Chris PeBenito <chpebeni@linux.microsoft.com>
>
> Acked-by: Stephen Smalley <stephen.smalley.work@gmail.com>

Applied.
diff mbox series

Patch

diff --git a/libselinux/src/label_file.c b/libselinux/src/label_file.c
index 6eeeea68..726394ca 100644
--- a/libselinux/src/label_file.c
+++ b/libselinux/src/label_file.c
@@ -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);