<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://bugs.webkit.org/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.4.1"
          urlbase="https://bugs.webkit.org/"
          
          maintainer="admin@webkit.org"
>

    <bug>
          <bug_id>112099</bug_id>
          
          <creation_ts>2013-03-11 20:09:39 -0700</creation_ts>
          <short_desc>GIF decoder can read off end of buffer</short_desc>
          <delta_ts>2013-03-19 16:10:48 -0700</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WebKit</product>
          <component>Images</component>
          <version>528+ (Nightly build)</version>
          <rep_platform>Unspecified</rep_platform>
          <op_sys>Unspecified</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>P2</priority>
          <bug_severity>Normal</bug_severity>
          <target_milestone>---</target_milestone>
          <dependson>111144</dependson>
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Peter Kasting">pkasting</reporter>
          <assigned_to name="Hin-Chung Lam">hclam</assigned_to>
          <cc>hclam</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>853025</commentid>
    <comment_count>0</comment_count>
    <who name="Peter Kasting">pkasting</who>
    <bug_when>2013-03-11 20:09:39 -0700</bug_when>
    <thetext>Noticed while reviewing various GIF decoder patches.  hclam -- want to fix this while you&apos;re touching this stuff?

The bug is that the GIFNetscapeExtensionBlock state of the parser reads the block length from the image file, but then the GIFConsumeNetscapeExtension assumes the block length is at least the 3 that the spec requires.  Therefore, an image can specify &quot;1&quot; or &quot;2&quot; here and then end after that many more bytes, and the parser will happily read another two or one bytes off the end of the buffer.

I believe the correct fix is that the GIFNetscapeExtensionBlock state should call GETN(std::max(3, *currentComponent), GIFConsumeNetscapeExtension);.  A comment explaining this wouldn&apos;t be amiss.

I suspect Gecko has the same problem.

The Chrome security guys looked at this and declared it not a security bug, since there seems to be no way to use this OOB read to malicious effect (since it just controls the image loop count).</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>853027</commentid>
    <comment_count>1</comment_count>
    <who name="Hin-Chung Lam">hclam</who>
    <bug_when>2013-03-11 20:14:19 -0700</bug_when>
    <thetext>Okay, I&apos;ll fix it.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>858844</commentid>
    <comment_count>2</comment_count>
    <who name="Hin-Chung Lam">hclam</who>
    <bug_when>2013-03-19 16:10:38 -0700</bug_when>
    <thetext>The fix is landed in https://bugs.webkit.org/show_bug.cgi?id=111144</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>