sensord: check type whether it is a regular file or not 13/139313/1
authorkibak.yoon <kibak.yoon@samsung.com>
Tue, 18 Jul 2017 09:59:59 +0000 (18:59 +0900)
committerkibak.yoon <kibak.yoon@samsung.com>
Tue, 18 Jul 2017 09:59:59 +0000 (18:59 +0900)
Change-Id: I8b72cd6702def0a57d5ce570cb183d90f43519f6
Signed-off-by: kibak.yoon <kibak.yoon@samsung.com>
src/server/server.cpp

index 22b3987..237f658 100644 (file)
@@ -20,6 +20,7 @@
 #include "server.h"
 
 #include <unistd.h>
+#include <sys/stat.h>
 #include <systemd/sd-daemon.h>
 #include <sensor_log.h>
 #include <command_types.h>
@@ -112,6 +113,14 @@ void server::deinit(void)
 
 static void set_cal_data(const char *path)
 {
+       struct stat file_stat;
+
+       if (lstat(path, &file_stat) != 0)
+               return;
+
+       if (!S_ISREG(file_stat.st_mode))
+               return;
+
        FILE *fp = fopen(path, "w");
        retm_if(!fp, "There is no calibration file[%s]", path);