Skip to content

Commit 4c5dbf1

Browse files
committed
Merge branch 'js/ming-strftime'
* js/ming-strftime: mingw: abort on invalid strftime formats
2 parents e2a37ec + 9ee0540 commit 4c5dbf1

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

compat/mingw.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -761,6 +761,17 @@ int mingw_utime (const char *file_name, const struct utimbuf *times)
761761
return rc;
762762
}
763763

764+
#undef strftime
765+
size_t mingw_strftime(char *s, size_t max,
766+
const char *format, const struct tm *tm)
767+
{
768+
size_t ret = strftime(s, max, format, tm);
769+
770+
if (!ret && errno == EINVAL)
771+
die("invalid strftime format: '%s'", format);
772+
return ret;
773+
}
774+
764775
unsigned int sleep (unsigned int seconds)
765776
{
766777
Sleep(seconds*1000);

compat/mingw.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -361,6 +361,9 @@ int mingw_fstat(int fd, struct stat *buf);
361361

362362
int mingw_utime(const char *file_name, const struct utimbuf *times);
363363
#define utime mingw_utime
364+
size_t mingw_strftime(char *s, size_t max,
365+
const char *format, const struct tm *tm);
366+
#define strftime mingw_strftime
364367

365368
pid_t mingw_spawnvpe(const char *cmd, const char **argv, char **env,
366369
const char *dir,

0 commit comments

Comments
 (0)