Skip to content

Commit

Permalink
Merge branch 'mingw-strftime'
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
dscho committed Oct 4, 2016
2 parents 953b03c + 6112fa2 commit e408b09
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
11 changes: 11 additions & 0 deletions compat/mingw.c
Original file line number Diff line number Diff line change
Expand Up @@ -888,6 +888,17 @@ int mingw_utime (const char *file_name, const struct utimbuf *times)
return rc;
}

#undef strftime
size_t mingw_strftime(char *s, size_t max,
const char *format, const struct tm *tm)
{
size_t ret = strftime(s, max, format, tm);

if (!ret && errno == EINVAL)
die("invalid strftime format: '%s'", format);
return ret;
}

unsigned int sleep (unsigned int seconds)
{
Sleep(seconds*1000);
Expand Down
3 changes: 3 additions & 0 deletions compat/mingw.h
Original file line number Diff line number Diff line change
Expand Up @@ -397,6 +397,9 @@ extern int (*lstat)(const char *file_name, struct stat *buf);

int mingw_utime(const char *file_name, const struct utimbuf *times);
#define utime mingw_utime
size_t mingw_strftime(char *s, size_t max,
const char *format, const struct tm *tm);
#define strftime mingw_strftime

pid_t mingw_spawnvpe(const char *cmd, const char **argv, char **env,
const char *dir,
Expand Down

0 comments on commit e408b09

Please sign in to comment.