From af19f3f1e6c18ca870be9948d6795fec9ad5104f Mon Sep 17 00:00:00 2001 From: alkasethi Date: Wed, 16 Jan 2019 20:11:17 +0530 Subject: [PATCH] [SATDEVKIT-2522]Symbolic link issues handled Change-Id: I557c06556fc5d600d10c5e5a6b199c1a8ac5d3ad Signed-off-by: alkasethi --- src/sdb.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/sdb.c b/src/sdb.c index ba6e1ac..68e20f4 100644 --- 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"); -- 2.7.4