Fix security SVACE issue 46/139946/1
authorHeeyong Song <heeyong.song@samsung.com>
Fri, 21 Jul 2017 06:27:45 +0000 (15:27 +0900)
committerHeeyong Song <heeyong.song@samsung.com>
Fri, 21 Jul 2017 06:29:24 +0000 (15:29 +0900)
Change-Id: I44700728866ffef5728bc45433455059a9eb882f

adaptors/base/fps-tracker.cpp

index 7c68e47..6ae5a4d 100644 (file)
@@ -21,6 +21,7 @@
 // EXTERNAL INCLUDES
 #include <cstdio>
 #include <cmath>
+#include <sys/stat.h>
 
 // INTERNAL INCLUDES
 #include <base/environment-options.h>
@@ -82,6 +83,19 @@ void FpsTracker::OutputFPSRecord()
   float fps = mFrameCount / mElapsedTime;
   DALI_LOG_FPS("Frame count %.0f, elapsed time %.1fs, FPS: %.2f\n", mFrameCount, mElapsedTime, fps );
 
+  struct stat fileStat;
+
+  // Check file path
+  if( lstat( DALI_TEMP_UPDATE_FPS_FILE, &fileStat ) != 0 )
+  {
+    return;
+  }
+
+  if( !S_ISREG( fileStat.st_mode ) )
+  {
+    return;
+  }
+
   // Dumps out the frame rate.
   FILE* outfile = fopen( DALI_TEMP_UPDATE_FPS_FILE, "w" );
   if( outfile )