Allow icon info with empty bitmap data.
@@ -95,7 +95,7 @@ BOOL utf8_string_to_rail_string(const char* string, RAIL_UNICODE_STRING* unicode
/* See [MS-RDPERP] 2.2.1.2.3 Icon Info (TS_ICON_INFO) */
static BOOL update_read_icon_info(wStream* s, ICON_INFO* iconInfo)
{
- BYTE* newBitMask;
+ BYTE* newBitMask = NULL;
if (Stream_GetRemainingLength(s) < 8)
return FALSE;
@@ -137,6 +137,8 @@ static BOOL update_read_icon_info(wStream* s, ICON_INFO* iconInfo)
Stream_Read_UINT16(s, iconInfo->cbBitsColor); /* cbBitsColor (2 bytes) */
/* bitsMask */
+ if (iconInfo->cbBitsMask > 0)
+ {
newBitMask = (BYTE*)realloc(iconInfo->bitsMask, iconInfo->cbBitsMask);
if (!newBitMask)
@@ -150,19 +152,16 @@ static BOOL update_read_icon_info(wStream* s, ICON_INFO* iconInfo)
if (Stream_GetRemainingLength(s) < iconInfo->cbBitsMask)
return FALSE;
Stream_Read(s, iconInfo->bitsMask, iconInfo->cbBitsMask);
-
- /* colorTable */
- if (iconInfo->colorTable == NULL)
- {
- if (iconInfo->cbColorTable)
- {
- iconInfo->colorTable = (BYTE*)malloc(iconInfo->cbColorTable);
-
- if (!iconInfo->colorTable)
- return FALSE;
}
+ else
+ {
+ free(iconInfo->bitsMask);
+ iconInfo->bitsMask = NULL;
+ iconInfo->cbBitsMask = 0;
}
- else if (iconInfo->cbColorTable)
+
+ /* colorTable */
+ if (iconInfo->cbColorTable > 0)
{
BYTE* new_tab;
new_tab = (BYTE*)realloc(iconInfo->colorTable, iconInfo->cbColorTable);
@@ -190,6 +189,8 @@ static BOOL update_read_icon_info(wStream* s, ICON_INFO* iconInfo)
}
/* bitsColor */
+ if (iconInfo->cbBitsColor > 0)
+ {
newBitMask = (BYTE*)realloc(iconInfo->bitsColor, iconInfo->cbBitsColor);
if (!newBitMask)
@@ -203,6 +204,13 @@ static BOOL update_read_icon_info(wStream* s, ICON_INFO* iconInfo)
if (Stream_GetRemainingLength(s) < iconInfo->cbBitsColor)
return FALSE;
Stream_Read(s, iconInfo->bitsColor, iconInfo->cbBitsColor);
+ }
+ else
+ {
+ free(iconInfo->bitsColor);
+ iconInfo->bitsColor = NULL;
+ iconInfo->cbBitsColor = 0;
+ }
return TRUE;
}
