From 11b7076a435838e3e6dfea7870285e188547a66f Mon Sep 17 00:00:00 2001 From: topjohnwu Date: Thu, 5 Dec 2019 17:34:50 -0500 Subject: [PATCH] Fix broken getxattr calls --- native/jni/utils/selinux.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/native/jni/utils/selinux.cpp b/native/jni/utils/selinux.cpp index 785b61288..f41fd8106 100644 --- a/native/jni/utils/selinux.cpp +++ b/native/jni/utils/selinux.cpp @@ -55,7 +55,7 @@ static int __setcon(const char *ctx) { static int __getfilecon(const char *path, char **ctx) { char buf[1024]; int rc = syscall(__NR_getxattr, path, XATTR_NAME_SELINUX, buf, sizeof(buf) - 1); - if (rc == 0) + if (rc >= 0) *ctx = strdup(buf); return rc; } @@ -63,7 +63,7 @@ static int __getfilecon(const char *path, char **ctx) { static int __lgetfilecon(const char *path, char **ctx) { char buf[1024]; int rc = syscall(__NR_lgetxattr, path, XATTR_NAME_SELINUX, buf, sizeof(buf) - 1); - if (rc == 0) + if (rc >= 0) *ctx = strdup(buf); return rc; } @@ -71,7 +71,7 @@ static int __lgetfilecon(const char *path, char **ctx) { static int __fgetfilecon(int fd, char **ctx) { char buf[1024]; int rc = syscall(__NR_fgetxattr, fd, XATTR_NAME_SELINUX, buf, sizeof(buf) - 1); - if (rc == 0) + if (rc >= 0) *ctx = strdup(buf); return rc; }