svace security issue fix 01/236801/6 accepted/tizen/unified/20200623.123920 submit/tizen/20200623.023228
authorsattdeepan.d <sattdeepan.d@samsung.com>
Wed, 17 Jun 2020 12:09:01 +0000 (17:39 +0530)
committerSeungha Son <seungha.son@samsung.com>
Mon, 22 Jun 2020 10:07:35 +0000 (19:07 +0900)
Change-Id: I85b4c82a96e42d3a08acd1ec3f2f25742205aa4e
Signed-off-by: Seungha Son <seungha.son@samsung.com>
src/atrace_helper/main.cc
src/atrace_helper/procfs_utils.cc

index 35c36b00a9fbb88ef3f028aa2243ae2ae95c3c6b..6079c00f93e9110f7ded4066e37598617dc629da 100644 (file)
@@ -108,7 +108,7 @@ int main(int argc, char** argv) {
   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);
   }
index bf1ee4ad16d53a9bbccb3e418287fd71d405c198..5726a24742e84ee20184bbacf9ec18425c746ba7 100644 (file)
@@ -28,7 +28,7 @@ inline void ReadProcString(int pid, const char* path, char* buf, size_t size) {
 
 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';
@@ -74,13 +74,13 @@ void ReadProcessThreads(ProcessInfo* process) {
     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");