Skip to content

Commit a62c82a

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 8920461 + 036b75e commit a62c82a

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

931+
#undef strftime
932+
size_t mingw_strftime(char *s, size_t max,
933+
const char *format, const struct tm *tm)
934+
{
935+
size_t ret = strftime(s, max, format, tm);
936+
937+
if (!ret && errno == EINVAL)
938+
die("invalid strftime format: '%s'", format);
939+
return ret;
940+
}
941+
931942
unsigned int sleep (unsigned int seconds)
932943
{
933944
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)