Skip to content

Commit a94814a

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 45539c9 + cdc2f27 commit a94814a

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
@@ -930,6 +930,17 @@ int mingw_utime (const char *file_name, const struct utimbuf *times)
930930
return rc;
931931
}
932932

933+
#undef strftime
934+
size_t mingw_strftime(char *s, size_t max,
935+
const char *format, const struct tm *tm)
936+
{
937+
size_t ret = strftime(s, max, format, tm);
938+
939+
if (!ret && errno == EINVAL)
940+
die("invalid strftime format: '%s'", format);
941+
return ret;
942+
}
943+
933944
unsigned int sleep (unsigned int seconds)
934945
{
935946
Sleep(seconds*1000);

compat/mingw.h

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

447447
int mingw_utime(const char *file_name, const struct utimbuf *times);
448448
#define utime mingw_utime
449+
size_t mingw_strftime(char *s, size_t max,
450+
const char *format, const struct tm *tm);
451+
#define strftime mingw_strftime
449452

450453
pid_t mingw_spawnvpe(const char *cmd, const char **argv, char **env,
451454
const char *dir,

0 commit comments

Comments
 (0)