[SATDEVKIT-2522]Symbolic link issues handled 61/197861/3
authoralkasethi <alka.sethi@samsung.com>
Wed, 16 Jan 2019 14:41:17 +0000 (20:11 +0530)
committeralkasethi <alka.sethi@samsung.com>
Wed, 16 Jan 2019 14:55:50 +0000 (20:25 +0530)
Change-Id: I557c06556fc5d600d10c5e5a6b199c1a8ac5d3ad
Signed-off-by: alkasethi <alka.sethi@samsung.com>
src/sdb.c

index ba6e1ac..68e20f4 100644 (file)
--- a/src/sdb.c
+++ b/src/sdb.c
@@ -1307,16 +1307,26 @@ static void booting_done_signal_subscriber(GDBusConnection *connection,
 
     D("received the \"%s\" signal\n", signal);
 
+    char cRealPath[PATH_MAX]= {0, };
     booting_done = 1;
     if (access(SDBD_BOOT_INFO_FILE, F_OK) == 0) {
         I("booting is already done\n");
     } else {
         FILE *info_file = fopen(SDBD_BOOT_INFO_FILE, "w");
         if (info_file != NULL) {
-            fprintf(info_file, "%d", 1);
-            fclose(info_file);
+               if (realpath(SDBD_BOOT_INFO_FILE, cRealPath) != NULL) {
+                        if (strcmp(SDBD_BOOT_INFO_FILE, cRealPath) == 0) {
+                                fprintf(info_file, "%d", 1);
+                                I("booting is done\n");
+                        } else {
+                                D("Path has symbolic link, security risk \n");
+                                return;
+                        }
+               } else {
+                       D("Getting realpath failed\n");
+               }
+               fclose(info_file);
         }
-        I("booting is done\n");
     }
 
     I("handled the booting done signal\n");