[lz4io] Refuse to set file stat for non-regular files
authorNick Terrell <terrelln@fb.com>
Fri, 5 Jan 2018 19:32:04 +0000 (11:32 -0800)
committerNick Terrell <terrelln@fb.com>
Fri, 5 Jan 2018 19:54:35 +0000 (11:54 -0800)
programs/util.h

index 1382cab..fc7f63e 100644 (file)
@@ -265,11 +265,17 @@ UTIL_STATIC void UTIL_waitForNextTick(void)
 #endif
 
 
+UTIL_STATIC int UTIL_isRegFile(const char* infilename);
+
+
 UTIL_STATIC int UTIL_setFileStat(const char *filename, stat_t *statbuf)
 {
     int res = 0;
     struct utimbuf timebuf;
 
+    if (!UTIL_isRegFile(filename))
+        return -1;
+
     timebuf.actime = time(NULL);
     timebuf.modtime = statbuf->st_mtime;
     res += utime(filename, &timebuf);  /* set access and modification times */