From b8e04d0b842c77047bc59edc5b369e3f5a745d0a Mon Sep 17 00:00:00 2001 From: Ron Yorston Date: Sun, 19 Jan 2020 11:30:47 +0000 Subject: mingw: fix off-by-one error in mingw_strftime() When a format specification is replaced the loop variable 't' should point to the last character of the replacement string in the new format buffer. In an extreme case if the original format string is "%z" and tm->tm_isdst is negative to indicate that no DST information is available the replacement string will be empty and 't' will point to the location before the start of the new format buffer. This is OK. --- win32/mingw.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'win32') diff --git a/win32/mingw.c b/win32/mingw.c index e64f48bf1..3a3b3cd63 100644 --- a/win32/mingw.c +++ b/win32/mingw.c @@ -1377,7 +1377,7 @@ size_t mingw_strftime(char *buf, size_t max, const char *format, const struct tm m = t - fmt; newfmt = xasprintf("%s%s%s", fmt, replace, t+2); free(fmt); - t = newfmt + m + strlen(replace); + t = newfmt + m + strlen(replace) - 1; fmt = newfmt; } } -- cgit v1.2.3-55-g6feb