Changeset 145569 in webkit


Ignore:
Timestamp:
Mar 12, 2013, 11:27:07 AM (12 years ago)
Author:
commit-queue@webkit.org
Message:

Webkit unable to show gifs with applcation extension string shorter than 11 bytes
https://bugs.webkit.org/show_bug.cgi?id=110620

Patch by Viatcheslav Ostapenko <sl.ostapenko@samsung.com> on 2013-03-12
Reviewed by Laszlo Gombos.

Source/WebCore:

Use actual block size for gifs application extension string even if it is below 11 bytes
to be able to decode this kind of gifs.

Test: fast/images/gif-short-app-extension-string.html

  • platform/image-decoders/gif/GIFImageReader.cpp:

(GIFImageReader::decodeInternal):

LayoutTests:

Test that webkit is able to decode gifs with short application extension string.

  • fast/images/gif-short-app-extension-string-expected.png: Added.
  • fast/images/gif-short-app-extension-string-expected.txt: Added.
  • fast/images/gif-short-app-extension-string.html: Added.
  • fast/images/resources/short-app-extension-string.gif: Added.
Location:
trunk
Files:
4 added
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r145555 r145569  
     12013-03-12  Viatcheslav Ostapenko  <sl.ostapenko@samsung.com>
     2
     3        Webkit unable to show gifs with applcation extension string shorter than 11 bytes
     4        https://bugs.webkit.org/show_bug.cgi?id=110620
     5
     6        Reviewed by Laszlo Gombos.
     7
     8        Test that webkit is able to decode gifs with short application extension string.
     9
     10        * fast/images/gif-short-app-extension-string-expected.png: Added.
     11        * fast/images/gif-short-app-extension-string-expected.txt: Added.
     12        * fast/images/gif-short-app-extension-string.html: Added.
     13        * fast/images/resources/short-app-extension-string.gif: Added.
     14
    1152013-03-12  Zan Dobersek  <zdobersek@igalia.com>
    216
  • trunk/Source/WebCore/ChangeLog

    r145567 r145569  
     12013-03-12  Viatcheslav Ostapenko  <sl.ostapenko@samsung.com>
     2
     3        Webkit unable to show gifs with applcation extension string shorter than 11 bytes
     4        https://bugs.webkit.org/show_bug.cgi?id=110620
     5
     6        Reviewed by Laszlo Gombos.
     7
     8        Use actual block size for gifs application extension string even if it is below 11 bytes
     9        to be able to decode this kind of gifs.
     10
     11        Test: fast/images/gif-short-app-extension-string.html
     12
     13        * platform/image-decoders/gif/GIFImageReader.cpp:
     14        (GIFImageReader::decodeInternal):
     15
    1162013-03-12  Sheriff Bot  <webkit.review.bot@gmail.com>
    217
  • trunk/Source/WebCore/platform/image-decoders/gif/GIFImageReader.cpp

    r144961 r145569  
    479479            GIFState es = GIFSkipBlock;
    480480
    481             // The GIF spec mandates lengths for three of the extensions below.
    482             // However, it's possible for GIFs in the wild to deviate. For example,
    483             // some GIFs that embed ICC color profiles using GIFApplicationExtension
    484             // violate the spec and treat this extension block like a sort of
    485             // "extension + data" block, giving a size greater than 11 and filling the
    486             // remaining bytes with data (then following with more data blocks as
    487             // needed), instead of placing a true data block just after the 11 byte
    488             // extension block.
    489             //
    490             // Accordingly, if the specified length is larger than the required value,
    491             // we use it. If it's smaller, then we enforce the spec value, because the
    492             // parsers for these extensions expect to have the specified number of
    493             // bytes available, and if we don't ensure that, they could read off the
    494             // end of the heap buffer. (In this case, it's likely the GIF is corrupt
    495             // and we'll soon fail to decode anyway.)
    496481            switch (*currentComponent) {
    497482            case 0xf9:
    498483                es = GIFControlExtension;
     484                // The GIF spec mandates that the GIFControlExtension header block length is 4 bytes,
     485                // and the parser for this block reads 4 bytes, so we must enforce that the buffer
     486                // contains at least this many bytes. If the GIF specifies a different length, we
     487                // allow that, so long as it's larger; the additional data will simply be ignored.
    499488                bytesInBlock = std::max(bytesInBlock, static_cast<size_t>(4));
    500489                break;
    501490
     491            // The GIF spec also specifies the lengths of the following two extensions' headers
     492            // (as 12 and 11 bytes, respectively). Because we ignore the plain text extension entirely
     493            // and sanity-check the actual length of the application extension header before reading it,
     494            // we allow GIFs to deviate from these values in either direction. This is important for
     495            // real-world compatibility, as GIFs in the wild exist with application extension headers
     496            // that are both shorter and longer than 11 bytes.
    502497            case 0x01:
    503498                // ignoring plain text extension
    504                 bytesInBlock = std::max(bytesInBlock, static_cast<size_t>(12));
    505499                break;
    506500
    507501            case 0xff:
    508502                es = GIFApplicationExtension;
    509                 bytesInBlock = std::max(bytesInBlock, static_cast<size_t>(11));
    510503                break;
    511504
     
    579572        case GIFApplicationExtension: {
    580573            // Check for netscape application extension.
    581             if (!strncmp((char*)currentComponent, "NETSCAPE2.0", 11) || !strncmp((char*)currentComponent, "ANIMEXTS1.0", 11))
     574            if (m_bytesToConsume == 11
     575                && (!strncmp((char*)currentComponent, "NETSCAPE2.0", 11) || !strncmp((char*)currentComponent, "ANIMEXTS1.0", 11)))
    582576                GETN(1, GIFNetscapeExtensionBlock);
    583577            else
Note: See TracChangeset for help on using the changeset viewer.