Make sure logs are always ended with newline

This commit is contained in:
topjohnwu
2022-09-09 04:29:50 -07:00
parent 44029875a6
commit a66a3b7438
19 changed files with 76 additions and 47 deletions
+4 -4
View File
@@ -71,7 +71,7 @@ static void update_pkg_uid(const string &pkg, bool remove) {
char buf[PATH_MAX] = {0};
// For each user
while ((entry = xreaddir(data_dir.get()))) {
snprintf(buf, sizeof(buf), "%s/%s", entry->d_name, pkg.data());
ssprintf(buf, sizeof(buf), "%s/%s", entry->d_name, pkg.data());
if (fstatat(dirfd(data_dir.get()), buf, &st, 0) == 0) {
int app_id = to_app_id(st.st_uid);
if (remove) {
@@ -242,7 +242,7 @@ static int add_list(const char *pkg, const char *proc) {
// Add to database
char sql[4096];
snprintf(sql, sizeof(sql),
ssprintf(sql, sizeof(sql),
"INSERT INTO denylist (package_name, process) VALUES('%s', '%s')", pkg, proc);
char *err = db_exec(sql);
db_err_cmd(err, return DenyResponse::ERROR)
@@ -286,9 +286,9 @@ static int rm_list(const char *pkg, const char *proc) {
char sql[4096];
if (proc[0] == '\0')
snprintf(sql, sizeof(sql), "DELETE FROM denylist WHERE package_name='%s'", pkg);
ssprintf(sql, sizeof(sql), "DELETE FROM denylist WHERE package_name='%s'", pkg);
else
snprintf(sql, sizeof(sql),
ssprintf(sql, sizeof(sql),
"DELETE FROM denylist WHERE package_name='%s' AND process='%s'", pkg, proc);
char *err = db_exec(sql);
db_err_cmd(err, return DenyResponse::ERROR)
+4 -4
View File
@@ -161,7 +161,7 @@ static vector<int> get_module_fds(bool is_64_bit) {
}
static bool get_exe(int pid, char *buf, size_t sz) {
snprintf(buf, sz, "/proc/%d/exe", pid);
ssprintf(buf, sz, "/proc/%d/exe", pid);
return xreadlink(buf, buf, sz) > 0;
}
@@ -191,7 +191,7 @@ static void connect_companion(int client, bool is_64_bit) {
// This fd has to survive exec
fcntl(fds[1], F_SETFD, 0);
char buf[16];
snprintf(buf, sizeof(buf), "%d", fds[1]);
ssprintf(buf, sizeof(buf), "%d", fds[1]);
execl(exe.data(), "", "zygisk", "companion", buf, (char *) nullptr);
exit(-1);
}
@@ -340,7 +340,7 @@ static void get_process_info(int client, const sock_cred *cred) {
if (!as_const(bits)[id]) {
// Either not a zygisk module, or incompatible
char buf[4096];
snprintf(buf, sizeof(buf), MODULEROOT "/%s/zygisk",
ssprintf(buf, sizeof(buf), MODULEROOT "/%s/zygisk",
module_list->operator[](id).name.data());
if (int dirfd = open(buf, O_RDONLY | O_CLOEXEC); dirfd >= 0) {
close(xopenat(dirfd, "unloaded", O_CREAT | O_RDONLY, 0644));
@@ -363,7 +363,7 @@ static void send_log_pipe(int fd) {
static void get_moddir(int client) {
int id = read_int(client);
char buf[4096];
snprintf(buf, sizeof(buf), MODULEROOT "/%s", module_list->operator[](id).name.data());
ssprintf(buf, sizeof(buf), MODULEROOT "/%s", module_list->operator[](id).name.data());
int dfd = xopen(buf, O_RDONLY | O_CLOEXEC);
send_fd(client, dfd);
close(dfd);
+1 -1
View File
@@ -44,7 +44,7 @@ int app_process_main(int argc, char *argv[]) {
if (fork_dont_care() == 0) {
// This fd has to survive exec
fcntl(fds[1], F_SETFD, 0);
snprintf(buf, sizeof(buf), "%d", fds[1]);
ssprintf(buf, sizeof(buf), "%d", fds[1]);
#if defined(__LP64__)
execlp("magisk", "", "zygisk", "passthrough", buf, "1", (char *) nullptr);
#else