char tmp_file[PATH_MAX + 4];
if (dump_to_file) {
unlink(out_file);
- sprintf(tmp_file, "%s.tmp", out_file);
+ snprintf(tmp_file, PATH_MAX + 4, "%s.tmp", out_file);
out_stream = fopen(tmp_file, "w");
CHECK(out_stream);
}
inline void ReadExePath(int pid, char* buf, size_t size) {
char exe_path[64];
- sprintf(exe_path, "/proc/%d/exe", pid);
+ snprintf(exe_path, sizeof(exe_path), "/proc/%d/exe", pid);
ssize_t res = readlink(exe_path, buf, size - 1);
if (res >= 0)
buf[res] = '\0';
return;
char tasks_path[64];
- sprintf(tasks_path, "/proc/%d/task", process->pid);
+ snprintf(tasks_path, sizeof(tasks_path), "/proc/%d/task", process->pid);
ForEachPidInProcPath(tasks_path, [process](int tid) {
if (process->threads.count(tid))
return;
ThreadInfo thread = { tid, "" };
char task_comm[64];
- sprintf(task_comm, "task/%d/comm", tid);
+ snprintf(task_comm, sizeof(task_comm), "task/%d/comm", tid);
ReadProcString(process->pid, task_comm, thread.name, sizeof(thread.name));
if (thread.name[0] == '\0' && process->is_app)
strcpy(thread.name, "UI Thread");