From: Nick Terrell Date: Fri, 5 Jan 2018 19:44:25 +0000 (-0800) Subject: [util] Refuse to set file stat on non-regular file X-Git-Tag: v1.3.4~1^2~92^2~2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=fd63140e1c79369e6d1e90bf1849569e1477f4ec;p=thirdparty%2Fzstd.git [util] Refuse to set file stat on non-regular file --- diff --git a/programs/util.h b/programs/util.h index af1fa7fca..4f22236a9 100644 --- a/programs/util.h +++ b/programs/util.h @@ -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 */