Skip to content

Commit e408b09

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 953b03c + 6112fa2 commit e408b09

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
@@ -397,6 +397,9 @@ extern int (*lstat)(const char *file_name, struct stat *buf);
397397

398398
int mingw_utime(const char *file_name, const struct utimbuf *times);
399399
#define utime mingw_utime
400+
size_t mingw_strftime(char *s, size_t max,
401+
const char *format, const struct tm *tm);
402+
#define strftime mingw_strftime
400403

401404
pid_t mingw_spawnvpe(const char *cmd, const char **argv, char **env,
402405
const char *dir,

0 commit comments

Comments
 (0)