parent
dd35224f92
commit
cfad7dd317
|
@ -57,10 +57,32 @@ static void kill_process(const char *name, bool multi = false) {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool validate(const char *s) {
|
||||||
|
bool dot = false;
|
||||||
|
for (char c; (c = *s); ++s) {
|
||||||
|
if ((c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z') ||
|
||||||
|
(c >= '0' && c <= '9') || c == '_') {
|
||||||
|
dot = false;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (c == '.') {
|
||||||
|
if (dot) // No consecutive dots
|
||||||
|
return false;
|
||||||
|
dot = true;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
static int add_list(const char *pkg, const char *proc = "") {
|
static int add_list(const char *pkg, const char *proc = "") {
|
||||||
if (proc[0] == '\0')
|
if (proc[0] == '\0')
|
||||||
proc = pkg;
|
proc = pkg;
|
||||||
|
|
||||||
|
if (!validate(pkg) || !validate(proc))
|
||||||
|
return HIDE_INVALID_PKG;
|
||||||
|
|
||||||
for (auto &hide : hide_set)
|
for (auto &hide : hide_set)
|
||||||
if (hide.first == pkg && hide.second == proc)
|
if (hide.first == pkg && hide.second == proc)
|
||||||
return HIDE_ITEM_EXIST;
|
return HIDE_ITEM_EXIST;
|
||||||
|
|
|
@ -147,8 +147,9 @@ int magiskhide_main(int argc, char *argv[]) {
|
||||||
case HIDE_NO_NS:
|
case HIDE_NO_NS:
|
||||||
fprintf(stderr, "Your kernel doesn't support mount namespace\n");
|
fprintf(stderr, "Your kernel doesn't support mount namespace\n");
|
||||||
break;
|
break;
|
||||||
|
case HIDE_INVALID_PKG:
|
||||||
/* Errors */
|
fprintf(stderr, "Invalid package / process name\n");
|
||||||
|
break;
|
||||||
case ROOT_REQUIRED:
|
case ROOT_REQUIRED:
|
||||||
fprintf(stderr, "Root is required for this operation\n");
|
fprintf(stderr, "Root is required for this operation\n");
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -58,5 +58,6 @@ enum {
|
||||||
HIDE_NOT_ENABLED,
|
HIDE_NOT_ENABLED,
|
||||||
HIDE_ITEM_EXIST,
|
HIDE_ITEM_EXIST,
|
||||||
HIDE_ITEM_NOT_EXIST,
|
HIDE_ITEM_NOT_EXIST,
|
||||||
HIDE_NO_NS
|
HIDE_NO_NS,
|
||||||
|
HIDE_INVALID_PKG
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue
Block a user