Microsoft GDI+ EMF Format Out-of-Bound Read Vulnerability
The Microsoft GDI+ implementation of the EMF format supports records corresponding to the ExtTextOutA() and PolyTextOutA() API functions. Both CEmfPlusEnumState::ExtTextOutA and CEmfPlusEnumState::PolyTextOutA handlers suffer from a security vulnerability in the handling of the 'offDx' record field, which is described in the format specification. The offset is supposed to address an array of 'Chars' (another field in the text records, specifying the number of characters to be displayed) double words, taking up a total of 4 * N bytes. However, instead of verifying that the provided record is sufficiently large to contain 4 * N bytes at the specified offset, it only checks if it can fit 4 bytes (completely ignoring the actual number of characters in the message, which can be larger than 1). This means that if the MultiByteToWideChar() function fails to convert the entire string, the function returns without calling CEmfPlusEnumState::PlayExtTextOut(), which is the function that actually performs the out-of-bound read.