git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@36598
c3d73ce0-8a6f-49c7-b76d-
6d57e0e08775
m_screenw = buf[0] + 256 * buf[1];
m_screenh = buf[2] + 256 * buf[3];
m_screenw = buf[0] + 256 * buf[1];
m_screenh = buf[2] + 256 * buf[3];
+ const int maxScreenSize = 4 << 10;
+ if ((m_screenw <= 0) || (m_screenw > maxScreenSize) || (m_screenh <= 0) || (m_screenh > maxScreenSize))
+ {
+ return wxGIF_INVFORMAT;
+ }
+
/* load global color map if available */
if ((buf[4] & 0x80) == 0x80)
{
/* load global color map if available */
if ((buf[4] & 0x80) == 0x80)
{
{
type = (unsigned char)m_f->GetC();
{
type = (unsigned char)m_f->GetC();
/* get initial code size from first byte in raster data */
bits = (unsigned char)m_f->GetC();
/* get initial code size from first byte in raster data */
bits = (unsigned char)m_f->GetC();
+ if (bits == 0)
+ {
+ Destroy();
+ return wxGIF_INVFORMAT;
+ }
/* decode image */
int result = dgif(pimg, interl, bits);
/* decode image */
int result = dgif(pimg, interl, bits);
{
Destroy();
return wxGIF_INVFORMAT;
{
Destroy();
return wxGIF_INVFORMAT;
if ((buf[8] & 0x80) == 0x80)
{
ncolors = 2 << (buf[8] & 0x07);
if ((buf[8] & 0x80) == 0x80)
{
ncolors = 2 << (buf[8] & 0x07);
+ if (ncolors <= 0)
+ {
+ Destroy();
+ return wxGIF_INVFORMAT;
+ }
+
wxFileOffset pos = m_f->TellI();
wxFileOffset numBytes = 3 * ncolors;
m_f->SeekI(numBytes, wxFromCurrent);
wxFileOffset pos = m_f->TellI();
wxFileOffset numBytes = 3 * ncolors;
m_f->SeekI(numBytes, wxFromCurrent);