Skip to content

Commit f5a4712

Browse files
committed
Merge branch 'mingw-strftime'
This topic branch works around an out-of-memory bug when the user specified a format via --date=format:<format> that strftime() does not like. Reported by Stefan Naewe. Signed-off-by: Johannes Schindelin <[email protected]>
2 parents f756951 + 9ddbc70 commit f5a4712

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
@@ -888,6 +888,17 @@ int mingw_utime (const char *file_name, const struct utimbuf *times)
888888
return rc;
889889
}
890890

891+
#undef strftime
892+
size_t mingw_strftime(char *s, size_t max,
893+
const char *format, const struct tm *tm)
894+
{
895+
size_t ret = strftime(s, max, format, tm);
896+
897+
if (!ret && errno == EINVAL)
898+
die("invalid strftime format: '%s'", format);
899+
return ret;
900+
}
901+
891902
unsigned int sleep (unsigned int seconds)
892903
{
893904
Sleep(seconds*1000);

compat/mingw.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -440,6 +440,9 @@ extern int (*lstat)(const char *file_name, struct stat *buf);
440440

441441
int mingw_utime(const char *file_name, const struct utimbuf *times);
442442
#define utime mingw_utime
443+
size_t mingw_strftime(char *s, size_t max,
444+
const char *format, const struct tm *tm);
445+
#define strftime mingw_strftime
443446

444447
pid_t mingw_spawnvpe(const char *cmd, const char **argv, char **env,
445448
const char *dir,

0 commit comments

Comments
 (0)