]> git.ipfire.org Git - thirdparty/zstd.git/commitdiff
[util] Refuse to set file stat on non-regular file
authorNick Terrell <terrelln@fb.com>
Fri, 5 Jan 2018 19:44:25 +0000 (11:44 -0800)
committerNick Terrell <terrelln@fb.com>
Fri, 5 Jan 2018 19:44:25 +0000 (11:44 -0800)
programs/util.h

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