msvcrt: Don't write past buffer in strftime.

Signed-off-by: Piotr Caban <piotr@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Piotr Caban 2019-09-30 16:52:07 +02:00 committed by Alexandre Julliard
parent b22236d1b1
commit 30913ff564
1 changed files with 4 additions and 2 deletions

View File

@ -1197,10 +1197,12 @@ static MSVCRT_size_t strftime_helper(char *str, MSVCRT_size_t max, const char *f
case 'T':
if(!strftime_int(str, &ret, max, mstm->tm_hour, alternate ? 0 : 2, 0, 23))
return 0;
str[ret++] = ':';
if(ret < max)
str[ret++] = ':';
if(!strftime_int(str, &ret, max, mstm->tm_min, alternate ? 0 : 2, 0, 59))
return 0;
str[ret++] = ':';
if(ret < max)
str[ret++] = ':';
if(!strftime_int(str, &ret, max, mstm->tm_sec, alternate ? 0 : 2, 0, 59))
return 0;
break;