<?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>12081</bug_id>
          
          <creation_ts>2007-01-02 13:25:39 -0800</creation_ts>
          <short_desc>Crash in Windows cookie code if cookies change between calls</short_desc>
          <delta_ts>2017-02-28 20:38:49 -0800</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WebKit</product>
          <component>Platform</component>
          <version>420+</version>
          <rep_platform>PC</rep_platform>
          <op_sys>Windows XP</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>WONTFIX</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>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Brett Wilson (Google)">brettw</reporter>
          <assigned_to name="Nobody">webkit-unassigned</assigned_to>
          <cc>ap</cc>
    
    <cc>aroben</cc>
    
    <cc>basuke</cc>
    
    <cc>bugs-webkit</cc>
    
    <cc>fujii</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>37659</commentid>
    <comment_count>0</comment_count>
    <who name="Brett Wilson (Google)">brettw</who>
    <bug_when>2007-01-02 13:25:39 -0800</bug_when>
    <thetext>in CookieJarWin.cpp, we call InternetGetCookie to get the length of the buffer, then call it again once a buffer of the correct size has been constructed. However, the cookies can change between these values if another process (or possibly some other cases, I&apos;m not sure) changes the cookies for the page between these calls.

In particular, if the cookies are deleted, we will make a string of length -1, causing a crash. If more cookies are added, the returned cookies will be truncated.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>37645</commentid>
    <comment_count>1</comment_count>
      <attachid>12172</attachid>
    <who name="Brett Wilson (Google)">brettw</who>
    <bug_when>2007-01-02 13:31:00 -0800</bug_when>
    <thetext>Created attachment 12172
Patch to CookieJarWin.cpp

This patch requests the cookies in a loop until the buffer is large enough to hold the cookies. As long as the length of the cookies doesn&apos;t grow monotonically, this  will terminate.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>33921</commentid>
    <comment_count>2</comment_count>
    <who name="Brett Wilson (Google)">brettw</who>
    <bug_when>2007-01-21 11:32:37 -0800</bug_when>
    <thetext>This patch still causes crashes. InternetGetCookie is buggy and will write one past the end of the buffer on ERROR_INVALID_PARAMETER. At the top of the loop:
  count = cookieBuffer.size() - 1;
and at the bottom, we need:
  cookieBuffer.resize(count + 1);
to compensate.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>4741</commentid>
    <comment_count>3</comment_count>
    <who name="Alexey Proskuryakov">ap</who>
    <bug_when>2007-07-15 01:13:13 -0700</bug_when>
    <thetext>Is this still a problem?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>3146</commentid>
    <comment_count>4</comment_count>
    <who name="Brett Wilson (Google)">brettw</who>
    <bug_when>2007-08-02 08:53:53 -0700</bug_when>
    <thetext>In Safari on Windows, this is not a problem. CookieJarWin.cpp is still in the tree, though, and it still has this bug, it just isn&apos;t used by anybody. Probably that file should just be deleted.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>3128</commentid>
    <comment_count>5</comment_count>
    <who name="Adam Roben (:aroben)">aroben</who>
    <bug_when>2007-08-02 11:59:24 -0700</bug_when>
    <thetext>(In reply to comment #4)
&gt; In Safari on Windows, this is not a problem. CookieJarWin.cpp is still in the
&gt; tree, though, and it still has this bug, it just isn&apos;t used by anybody.
&gt; Probably that file should just be deleted.

A patch to delete that file (and others not currently being used) would be welcome. There&apos;s no point keeping unused files in trunk, and they can always be resurrected from an old revision if desired.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>64848</commentid>
    <comment_count>6</comment_count>
    <who name="Brett Wilson (Google)">brettw</who>
    <bug_when>2007-12-20 11:22:15 -0800</bug_when>
    <thetext>It looks like this file is now used by the new Windows port. The buggy code is still there, though.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>66023</commentid>
    <comment_count>7</comment_count>
    <who name="Adam Roben (:aroben)">aroben</who>
    <bug_when>2008-01-02 06:50:24 -0800</bug_when>
    <thetext>(In reply to comment #6)
&gt; It looks like this file is now used by the new Windows port. The buggy code is
&gt; still there, though.

...but it sounds like we haven&apos;t seen this to be a problem in practice with the CFNetwork cookies implementation. Would still be nice to fix sometime, but it&apos;s not urgent.
</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1281971</commentid>
    <comment_count>8</comment_count>
    <who name="Basuke Suzuki">basuke</who>
    <bug_when>2017-02-28 15:01:48 -0800</bug_when>
    <thetext>Based on https://trac.webkit.org/changeset/176672 , this bug is no longer valid.</thetext>
  </long_desc>
      
          <attachment
              isobsolete="0"
              ispatch="1"
              isprivate="0"
          >
            <attachid>12172</attachid>
            <date>2007-01-02 13:31:00 -0800</date>
            <delta_ts>2010-06-10 15:22:02 -0700</delta_ts>
            <desc>Patch to CookieJarWin.cpp</desc>
            <filename>Cookie.diff</filename>
            <type>text/plain</type>
            <size>1977</size>
            <attacher name="Brett Wilson (Google)">brettw</attacher>
            
              <data encoding="base64">SW5kZXg6IENvb2tpZUphcldpbi5jcHAKPT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09
PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PQotLS0gQ29va2llSmFyV2luLmNwcAko
cmV2aXNpb24gMTgyMzMpCisrKyBDb29raWVKYXJXaW4uY3BwCSh3b3JraW5nIGNvcHkpCkBAIC0y
Nyw2ICsyNyw3IEBACiAjaW5jbHVkZSAiS1VSTC5oIgogI2luY2x1ZGUgIlBsYXRmb3JtU3RyaW5n
LmgiCiAjaW5jbHVkZSAiRGVwcmVjYXRlZFN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pbiB3aXRoIGxhcmdlciBidWZmZXIKKyAgICAgICAgY29va2llQnVmZmVyLnJlc2l6ZShjb3Vu
dCk7CisgICAgfQogfQogCiBib29sIGNvb2tpZXNFbmFibGVkKCkK
</data>

          </attachment>
      

    </bug>

</bugzilla>