mirror of
https://github.com/facebook/zstd.git
synced 2025-08-07 06:23:00 +03:00
[util] Refuse to set file stat on non-regular file
This commit is contained in:
@@ -246,11 +246,17 @@ UTIL_STATIC void UTIL_waitForNextTick(void)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
UTIL_STATIC int UTIL_isRegularFile(const char* infilename);
|
||||||
|
|
||||||
|
|
||||||
UTIL_STATIC int UTIL_setFileStat(const char *filename, stat_t *statbuf)
|
UTIL_STATIC int UTIL_setFileStat(const char *filename, stat_t *statbuf)
|
||||||
{
|
{
|
||||||
int res = 0;
|
int res = 0;
|
||||||
struct utimbuf timebuf;
|
struct utimbuf timebuf;
|
||||||
|
|
||||||
|
if (!UTIL_isRegularFile(filename))
|
||||||
|
return -1;
|
||||||
|
|
||||||
timebuf.actime = time(NULL);
|
timebuf.actime = time(NULL);
|
||||||
timebuf.modtime = statbuf->st_mtime;
|
timebuf.modtime = statbuf->st_mtime;
|
||||||
res += utime(filename, &timebuf); /* set access and modification times */
|
res += utime(filename, &timebuf); /* set access and modification times */
|
||||||
|
Reference in New Issue
Block a user