mirror of https://github.com/OpenVPN/openvpn-gui
Fix potential string mishandling in LocalizedTime
Signed-off-by: Selva Nair <selva.nair@gmail.com>pull/524/head
parent
788a4c1f9e
commit
e5ab9d74bd
|
@ -114,16 +114,17 @@ LocalizedSystemTime(const SYSTEMTIME *st, wchar_t *buf, size_t size)
|
||||||
return date_size + time_size;
|
return date_size + time_size;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (size > 0) {
|
date_size = GetDateFormat(locale, DATE_SHORTDATE, st, NULL,
|
||||||
date_size = GetDateFormat(locale, DATE_SHORTDATE, st, NULL,
|
buf, size);
|
||||||
buf, size);
|
if (size > (size_t) date_size)
|
||||||
if (date_size)
|
{
|
||||||
buf[date_size - 1] = ' ';
|
|
||||||
}
|
|
||||||
if (size - date_size > 0) {
|
|
||||||
time_size = GetTimeFormat(locale, TIME_NOSECONDS, st, NULL,
|
time_size = GetTimeFormat(locale, TIME_NOSECONDS, st, NULL,
|
||||||
buf + date_size, size - date_size);
|
buf + date_size, size - date_size);
|
||||||
}
|
}
|
||||||
|
if (date_size > 0 && time_size > 0)
|
||||||
|
{
|
||||||
|
buf[date_size - 1] = L' '; /* replaces the NUL char in the middle */
|
||||||
|
}
|
||||||
return date_size + time_size;
|
return date_size + time_size;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue