Commit 6164432a authored by Zhiyi Zhang's avatar Zhiyi Zhang Committed by Alexandre Julliard

compstui: Fix a possible out-of-bounds write (Coverity).

When len is 256, (ARRAY_SIZE(title) - len) is 0. When LoadStringW() is called with the last parameter being zero, a WCHAR string pointer is stored at 'title + 256', writing title out of bounds.
parent 2b323dba
...@@ -478,18 +478,22 @@ static LONG create_property_sheetW(struct propsheet *ps, PROPSHEETUI_INFO_HEADER ...@@ -478,18 +478,22 @@ static LONG create_property_sheetW(struct propsheet *ps, PROPSHEETUI_INFO_HEADER
(!header->titleW || !(header->flags & PSUIHDRF_EXACT_PTITLE))) (!header->titleW || !(header->flags & PSUIHDRF_EXACT_PTITLE)))
{ {
len = wcslen(title); len = wcslen(title);
if (len < ARRAY_SIZE(title)) if (len < ARRAY_SIZE(title) - 1)
{
title[len++] = ' '; title[len++] = ' ';
LoadStringW(compstui_hmod, IDS_CPSUI_DEFAULT, title + len, ARRAY_SIZE(title) - len); LoadStringW(compstui_hmod, IDS_CPSUI_DEFAULT, title + len, ARRAY_SIZE(title) - len);
}
} }
if ((header->flags & PSUIHDRF_PROPTITLE) && if ((header->flags & PSUIHDRF_PROPTITLE) &&
(!header->titleW || !(header->flags & PSUIHDRF_EXACT_PTITLE))) (!header->titleW || !(header->flags & PSUIHDRF_EXACT_PTITLE)))
{ {
len = wcslen(title); len = wcslen(title);
if (len < ARRAY_SIZE(title)) if (len < ARRAY_SIZE(title) - 1)
{
title[len++] = ' '; title[len++] = ' ';
LoadStringW(compstui_hmod, IDS_CPSUI_PROPERTIES, title + len, ARRAY_SIZE(title) - len); LoadStringW(compstui_hmod, IDS_CPSUI_PROPERTIES, title + len, ARRAY_SIZE(title) - len);
}
} }
psh.nPages = ps->pages_cnt; psh.nPages = ps->pages_cnt;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment