diff options
author | Ron Yorston <rmy@pobox.com> | 2020-01-19 11:30:47 +0000 |
---|---|---|
committer | Ron Yorston <rmy@pobox.com> | 2020-01-19 11:30:47 +0000 |
commit | b8e04d0b842c77047bc59edc5b369e3f5a745d0a (patch) | |
tree | 2fa63e3967775f6c352778929766c0f18335280e | |
parent | 4b3b7975b2f28b067c593f45c7c7dda2d31bc250 (diff) | |
download | busybox-w32-b8e04d0b842c77047bc59edc5b369e3f5a745d0a.tar.gz busybox-w32-b8e04d0b842c77047bc59edc5b369e3f5a745d0a.tar.bz2 busybox-w32-b8e04d0b842c77047bc59edc5b369e3f5a745d0a.zip |
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.
-rw-r--r-- | win32/mingw.c | 2 |
1 files changed, 1 insertions, 1 deletions
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 | |||
1377 | m = t - fmt; | 1377 | m = t - fmt; |
1378 | newfmt = xasprintf("%s%s%s", fmt, replace, t+2); | 1378 | newfmt = xasprintf("%s%s%s", fmt, replace, t+2); |
1379 | free(fmt); | 1379 | free(fmt); |
1380 | t = newfmt + m + strlen(replace); | 1380 | t = newfmt + m + strlen(replace) - 1; |
1381 | fmt = newfmt; | 1381 | fmt = newfmt; |
1382 | } | 1382 | } |
1383 | } | 1383 | } |