Loading cmds/dumpstate/dumpstate.cpp +4 −4 Original line number Diff line number Diff line Loading @@ -124,7 +124,7 @@ void do_mountinfo(int pid, const char *name) { // Gets the the content of the /proc/PID/ns/mnt link, so only unique mount points // are added. sprintf(path, "/proc/%d/ns/mnt", pid); snprintf(path, sizeof(path), "/proc/%d/ns/mnt", pid); char linkname[PATH_MAX]; ssize_t r = readlink(path, linkname, PATH_MAX); if (r == -1) { Loading @@ -135,7 +135,7 @@ void do_mountinfo(int pid, const char *name) { if (mount_points.find(linkname) == mount_points.end()) { // First time this mount point was found: add it sprintf(path, "/proc/%d/mountinfo", pid); snprintf(path, sizeof(path), "/proc/%d/mountinfo", pid); if (add_zip_entry(ZIP_ROOT_DIR + path, path)) { mount_points.insert(linkname); } else { Loading Loading @@ -1050,7 +1050,7 @@ int main(int argc, char *argv[]) { char last_id[PROPERTY_VALUE_MAX]; property_get("dumpstate.last_id", last_id, "0"); id = strtoul(last_id, NULL, 10) + 1; sprintf(last_id, "%lu", id); snprintf(last_id, sizeof(last_id), "%lu", id); property_set("dumpstate.last_id", last_id); MYLOGI("dumpstate id: %lu\n", id); Loading Loading @@ -1315,7 +1315,7 @@ int main(int argc, char *argv[]) { /* check if user changed the suffix using system properties */ char key[PROPERTY_KEY_MAX]; char value[PROPERTY_VALUE_MAX]; sprintf(key, "dumpstate.%d.name", getpid()); snprintf(key, sizeof(key), "dumpstate.%d.name", getpid()); property_get(key, value, ""); bool change_suffix= false; if (value[0]) { Loading cmds/dumpstate/utils.cpp +10 −10 Original line number Diff line number Diff line Loading @@ -187,7 +187,7 @@ static void for_each_tid_helper(int pid, const char *cmdline, void *arg) { char taskpath[255]; for_each_tid_func *func = (for_each_tid_func *) arg; sprintf(taskpath, "/proc/%d/task", pid); snprintf(taskpath, sizeof(taskpath), "/proc/%d/task", pid); if (!(d = opendir(taskpath))) { printf("Failed to open %s (%s)\n", taskpath, strerror(errno)); Loading @@ -209,7 +209,7 @@ static void for_each_tid_helper(int pid, const char *cmdline, void *arg) { if (tid == pid) continue; sprintf(commpath,"/proc/%d/comm", tid); snprintf(commpath, sizeof(commpath), "/proc/%d/comm", tid); memset(comm, 0, sizeof(comm)); if ((fd = TEMP_FAILURE_RETRY(open(commpath, O_RDONLY | O_CLOEXEC))) < 0) { strcpy(comm, "N/A"); Loading Loading @@ -243,7 +243,7 @@ void show_wchan(int pid, int tid, const char *name) { memset(buffer, 0, sizeof(buffer)); sprintf(path, "/proc/%d/wchan", tid); snprintf(path, sizeof(path), "/proc/%d/wchan", tid); if ((fd = TEMP_FAILURE_RETRY(open(path, O_RDONLY | O_CLOEXEC))) < 0) { printf("Failed to open '%s' (%s)\n", path, strerror(errno)); return; Loading Loading @@ -308,7 +308,7 @@ void show_showtime(int pid, const char *name) { memset(buffer, 0, sizeof(buffer)); sprintf(path, "/proc/%d/stat", pid); snprintf(path, sizeof(path), "/proc/%d/stat", pid); if ((fd = TEMP_FAILURE_RETRY(open(path, O_RDONLY | O_CLOEXEC))) < 0) { printf("Failed to open '%s' (%s)\n", path, strerror(errno)); return; Loading Loading @@ -396,8 +396,8 @@ void do_showmap(int pid, const char *name) { char title[255]; char arg[255]; sprintf(title, "SHOW MAP %d (%s)", pid, name); sprintf(arg, "%d", pid); snprintf(title, sizeof(title), "SHOW MAP %d (%s)", pid, name); snprintf(arg, sizeof(arg), "%d", pid); run_command(title, 10, SU_PATH, "root", "showmap", "-q", arg, NULL); } Loading Loading @@ -1191,8 +1191,8 @@ void update_progress(int delta) { int new_total = weight_total * 1.2; MYLOGD("Adjusting total weight from %d to %d\n", weight_total, new_total); weight_total = new_total; sprintf(key, "dumpstate.%d.max", getpid()); sprintf(value, "%d", weight_total); snprintf(key, sizeof(key), "dumpstate.%d.max", getpid()); snprintf(value, sizeof(value), "%d", weight_total); int status = property_set(key, value); if (status) { MYLOGE("Could not update max weight by setting system property %s to %s: %d\n", Loading @@ -1200,8 +1200,8 @@ void update_progress(int delta) { } } sprintf(key, "dumpstate.%d.progress", getpid()); sprintf(value, "%d", progress); snprintf(key, sizeof(key), "dumpstate.%d.progress", getpid()); snprintf(value, sizeof(value), "%d", progress); if (progress % 100 == 0) { // We don't want to spam logcat, so only log multiples of 100. Loading Loading
cmds/dumpstate/dumpstate.cpp +4 −4 Original line number Diff line number Diff line Loading @@ -124,7 +124,7 @@ void do_mountinfo(int pid, const char *name) { // Gets the the content of the /proc/PID/ns/mnt link, so only unique mount points // are added. sprintf(path, "/proc/%d/ns/mnt", pid); snprintf(path, sizeof(path), "/proc/%d/ns/mnt", pid); char linkname[PATH_MAX]; ssize_t r = readlink(path, linkname, PATH_MAX); if (r == -1) { Loading @@ -135,7 +135,7 @@ void do_mountinfo(int pid, const char *name) { if (mount_points.find(linkname) == mount_points.end()) { // First time this mount point was found: add it sprintf(path, "/proc/%d/mountinfo", pid); snprintf(path, sizeof(path), "/proc/%d/mountinfo", pid); if (add_zip_entry(ZIP_ROOT_DIR + path, path)) { mount_points.insert(linkname); } else { Loading Loading @@ -1050,7 +1050,7 @@ int main(int argc, char *argv[]) { char last_id[PROPERTY_VALUE_MAX]; property_get("dumpstate.last_id", last_id, "0"); id = strtoul(last_id, NULL, 10) + 1; sprintf(last_id, "%lu", id); snprintf(last_id, sizeof(last_id), "%lu", id); property_set("dumpstate.last_id", last_id); MYLOGI("dumpstate id: %lu\n", id); Loading Loading @@ -1315,7 +1315,7 @@ int main(int argc, char *argv[]) { /* check if user changed the suffix using system properties */ char key[PROPERTY_KEY_MAX]; char value[PROPERTY_VALUE_MAX]; sprintf(key, "dumpstate.%d.name", getpid()); snprintf(key, sizeof(key), "dumpstate.%d.name", getpid()); property_get(key, value, ""); bool change_suffix= false; if (value[0]) { Loading
cmds/dumpstate/utils.cpp +10 −10 Original line number Diff line number Diff line Loading @@ -187,7 +187,7 @@ static void for_each_tid_helper(int pid, const char *cmdline, void *arg) { char taskpath[255]; for_each_tid_func *func = (for_each_tid_func *) arg; sprintf(taskpath, "/proc/%d/task", pid); snprintf(taskpath, sizeof(taskpath), "/proc/%d/task", pid); if (!(d = opendir(taskpath))) { printf("Failed to open %s (%s)\n", taskpath, strerror(errno)); Loading @@ -209,7 +209,7 @@ static void for_each_tid_helper(int pid, const char *cmdline, void *arg) { if (tid == pid) continue; sprintf(commpath,"/proc/%d/comm", tid); snprintf(commpath, sizeof(commpath), "/proc/%d/comm", tid); memset(comm, 0, sizeof(comm)); if ((fd = TEMP_FAILURE_RETRY(open(commpath, O_RDONLY | O_CLOEXEC))) < 0) { strcpy(comm, "N/A"); Loading Loading @@ -243,7 +243,7 @@ void show_wchan(int pid, int tid, const char *name) { memset(buffer, 0, sizeof(buffer)); sprintf(path, "/proc/%d/wchan", tid); snprintf(path, sizeof(path), "/proc/%d/wchan", tid); if ((fd = TEMP_FAILURE_RETRY(open(path, O_RDONLY | O_CLOEXEC))) < 0) { printf("Failed to open '%s' (%s)\n", path, strerror(errno)); return; Loading Loading @@ -308,7 +308,7 @@ void show_showtime(int pid, const char *name) { memset(buffer, 0, sizeof(buffer)); sprintf(path, "/proc/%d/stat", pid); snprintf(path, sizeof(path), "/proc/%d/stat", pid); if ((fd = TEMP_FAILURE_RETRY(open(path, O_RDONLY | O_CLOEXEC))) < 0) { printf("Failed to open '%s' (%s)\n", path, strerror(errno)); return; Loading Loading @@ -396,8 +396,8 @@ void do_showmap(int pid, const char *name) { char title[255]; char arg[255]; sprintf(title, "SHOW MAP %d (%s)", pid, name); sprintf(arg, "%d", pid); snprintf(title, sizeof(title), "SHOW MAP %d (%s)", pid, name); snprintf(arg, sizeof(arg), "%d", pid); run_command(title, 10, SU_PATH, "root", "showmap", "-q", arg, NULL); } Loading Loading @@ -1191,8 +1191,8 @@ void update_progress(int delta) { int new_total = weight_total * 1.2; MYLOGD("Adjusting total weight from %d to %d\n", weight_total, new_total); weight_total = new_total; sprintf(key, "dumpstate.%d.max", getpid()); sprintf(value, "%d", weight_total); snprintf(key, sizeof(key), "dumpstate.%d.max", getpid()); snprintf(value, sizeof(value), "%d", weight_total); int status = property_set(key, value); if (status) { MYLOGE("Could not update max weight by setting system property %s to %s: %d\n", Loading @@ -1200,8 +1200,8 @@ void update_progress(int delta) { } } sprintf(key, "dumpstate.%d.progress", getpid()); sprintf(value, "%d", progress); snprintf(key, sizeof(key), "dumpstate.%d.progress", getpid()); snprintf(value, sizeof(value), "%d", progress); if (progress % 100 == 0) { // We don't want to spam logcat, so only log multiples of 100. Loading