security check : null termination check
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / internal / builder / builder-filesystem.h
old mode 100644 (file)
new mode 100755 (executable)
index bbb77d7..d7118dd
@@ -46,7 +46,9 @@ inline std::string ExpandPath(const std::string &name)
 inline std::string ExePath(void)
 {
   char buf[256];
-  readlink("/proc/self/exe", buf, sizeof(buf));
+  ssize_t len = readlink("/proc/self/exe", buf, sizeof(buf) - 1);
+  len = len > 0 ? len : 0;
+  buf[len] = '\0';
   return std::string(buf);
 }