Fix security issue 19/140919/4
authorSuyeon Hwang <stom.hwang@samsung.com>
Thu, 27 Jul 2017 06:28:10 +0000 (15:28 +0900)
committerSuyeon Hwang <stom.hwang@samsung.com>
Mon, 31 Jul 2017 02:46:33 +0000 (11:46 +0900)
Change-Id: I5c2742843ddfb86cb5c052e8abaeba9739319466
Signed-off-by: Suyeon Hwang <stom.hwang@samsung.com>
common/vc_config_parser.c
common/vc_info_parser.c
server/vcd_recorder.c

index eb9c867..f8ed365 100644 (file)
@@ -54,7 +54,7 @@ static int __vc_config_parser_set_file_mode(const char* filename)
                return -1;
        }
 
-       if (0 > chmod(filename, 0666)) {
+       if (0 > chmod(filename, 0600)) {
                SLOG(LOG_ERROR, vc_config_tag(), "[ERROR] Fail to change file mode");
                return -1;
        }
index 566e83b..8fda8ae 100644 (file)
@@ -77,7 +77,7 @@ static int __vc_info_parser_set_file_mode(const char* filename)
                return -1;
        }
 
-       if (0 > chmod(filename, 0666)) {
+       if (0 > chmod(filename, 0600)) {
                SLOG(LOG_ERROR, vc_info_tag(), "[ERROR] Fail to change file mode");
                return -1;
        }
index f701b47..a1dfd2b 100644 (file)
@@ -837,11 +837,27 @@ int vcd_recorder_start()
        char normal_file_name[128] = {'\0',};
        g_count++;
 
-       snprintf(normal_file_name, sizeof(normal_file_name), "/tmp/vc_normal_%d_%d", getpid(), g_count);
+       while (1) {
+               snprintf(normal_file_name, sizeof(normal_file_name), "/tmp/vc_normal_%d_%d", getpid(), g_count);
+               ret = access(normal_file_name, 0);
+
+               if (0 == ret) {
+                       SLOG(LOG_ERROR, TAG_VCD, "[Recorder ERROR] File is already exist");
+                       if (0 == remove(normal_file_name)) {
+                               SLOG(LOG_DEBUG, TAG_VCD, "[Recorder] Remove file");
+                               break;
+                       } else {
+                               g_count++;
+                       }
+               } else {
+                       break;
+               }
+       }
+
        SLOG(LOG_DEBUG, TAG_VCD, "[Recorder] File normal name : %s", normal_file_name);
 
        /* open test file */
-       g_normal_file = fopen(normal_file_name, "wb+");
+       g_normal_file = fopen(normal_file_name, "wb+x");
        if (!g_normal_file) {
                SLOG(LOG_ERROR, TAG_VCD, "[Recorder ERROR] File not found!");
        }