Check sehandle before fixing permissions
Change-Id: I73ba5519bf650f0c7f0a683f311099ff13747155
diff --git a/fixPermissions.cpp b/fixPermissions.cpp
index b98a8c7..5d57b47 100644
--- a/fixPermissions.cpp
+++ b/fixPermissions.cpp
@@ -71,6 +71,10 @@
int fixPermissions::fixDataDataContexts(void) {
string dir = "/data/data/";
sehandle = selabel_open(SELABEL_CTX_FILE, selinux_options, 1);
+ if (!sehandle) {
+ LOGINFO("Unable to open /file_contexts\n");
+ return 0;
+ }
if (TWFunc::Path_Exists(dir)) {
fixContextsRecursively(dir, 0);
}
@@ -112,7 +116,10 @@
struct stat sb;
string dir, androiddir;
sehandle = selabel_open(SELABEL_CTX_FILE, selinux_options, 1);
-
+ if (!sehandle) {
+ LOGINFO("Unable to open /file_contexts\n");
+ return 0;
+ }
if (TWFunc::Path_Exists("/data/media/0"))
dir = "/data/media/0";
else