Commit 11b7076a authored by topjohnwu's avatar topjohnwu

Fix broken getxattr calls

parent 291c718b
...@@ -55,7 +55,7 @@ static int __setcon(const char *ctx) { ...@@ -55,7 +55,7 @@ static int __setcon(const char *ctx) {
static int __getfilecon(const char *path, char **ctx) { static int __getfilecon(const char *path, char **ctx) {
char buf[1024]; char buf[1024];
int rc = syscall(__NR_getxattr, path, XATTR_NAME_SELINUX, buf, sizeof(buf) - 1); int rc = syscall(__NR_getxattr, path, XATTR_NAME_SELINUX, buf, sizeof(buf) - 1);
if (rc == 0) if (rc >= 0)
*ctx = strdup(buf); *ctx = strdup(buf);
return rc; return rc;
} }
...@@ -63,7 +63,7 @@ static int __getfilecon(const char *path, char **ctx) { ...@@ -63,7 +63,7 @@ static int __getfilecon(const char *path, char **ctx) {
static int __lgetfilecon(const char *path, char **ctx) { static int __lgetfilecon(const char *path, char **ctx) {
char buf[1024]; char buf[1024];
int rc = syscall(__NR_lgetxattr, path, XATTR_NAME_SELINUX, buf, sizeof(buf) - 1); int rc = syscall(__NR_lgetxattr, path, XATTR_NAME_SELINUX, buf, sizeof(buf) - 1);
if (rc == 0) if (rc >= 0)
*ctx = strdup(buf); *ctx = strdup(buf);
return rc; return rc;
} }
...@@ -71,7 +71,7 @@ static int __lgetfilecon(const char *path, char **ctx) { ...@@ -71,7 +71,7 @@ static int __lgetfilecon(const char *path, char **ctx) {
static int __fgetfilecon(int fd, char **ctx) { static int __fgetfilecon(int fd, char **ctx) {
char buf[1024]; char buf[1024];
int rc = syscall(__NR_fgetxattr, fd, XATTR_NAME_SELINUX, buf, sizeof(buf) - 1); int rc = syscall(__NR_fgetxattr, fd, XATTR_NAME_SELINUX, buf, sizeof(buf) - 1);
if (rc == 0) if (rc >= 0)
*ctx = strdup(buf); *ctx = strdup(buf);
return rc; return rc;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment