libselinux: Fix selabel_lookup() for the root dir.

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

Signed-off-by: Chris PeBenito <chpebeni@linux.microsoft.com>
Acked-by: Stephen Smalley <stephen.smalley.work@gmail.com>
This commit is contained in:
Chris PeBenito 2020-09-11 15:56:14 -04:00 committed by Stephen Smalley
parent 734e4beb55
commit 075f9cfe7a

View File

@ -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);