* src/selinux.c (restorecon_private): Check for correct error code
from [lf]getfilecon(). Note gnulib ensures these functions
always return -1 on error. Also indicate return with an error if
context_new() fails.
---
src/selinux.c | 6 ++++--
1 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/src/selinux.c b/src/selinux.c
index e708b55..afb3959 100644
--- a/src/selinux.c
+++ b/src/selinux.c
@@ -193,15 +193,17 @@ restorecon_private (char const *path, bool preserve)
if (fd)
{
rc = fgetfilecon (fd, &tcon);
- if (!rc)
+ if (rc < 0)
goto quit;
}
else
{
rc = lgetfilecon (path, &tcon);
- if (!rc)
+ if (rc < 0)
goto quit;
}
+
+ rc = -1;
tcontext = context_new (tcon);
if (!tcontext)
goto quit;
--
1.7.6.4