<?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>59949</bug_id>
          
          <creation_ts>2011-05-02 11:03:01 -0700</creation_ts>
          <short_desc>Avoid potential buffer overflow in WTFLog() and WTFLogVerbose()</short_desc>
          <delta_ts>2011-05-02 11:20:47 -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>New Bugs</component>
          <version>528+ (Nightly build)</version>
          <rep_platform>Other</rep_platform>
          <op_sys>OS X 10.5</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>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Jeff Miller">jeffm</reporter>
          <assigned_to name="Jeff Miller">jeffm</assigned_to>
          <cc>ap</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>396478</commentid>
    <comment_count>0</comment_count>
    <who name="Jeff Miller">jeffm</who>
    <bug_when>2011-05-02 11:03:01 -0700</bug_when>
    <thetext>Avoid potential buffer underrun in WTFLog() and WTFLogVerbose()</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>396483</commentid>
    <comment_count>1</comment_count>
      <attachid>91941</attachid>
    <who name="Jeff Miller">jeffm</who>
    <bug_when>2011-05-02 11:07:47 -0700</bug_when>
    <thetext>Created attachment 91941
Avoid potential buffer underrun in WTFLog() and WTFLogVerbose()</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>396489</commentid>
    <comment_count>2</comment_count>
      <attachid>91941</attachid>
    <who name="Alexey Proskuryakov">ap</who>
    <bug_when>2011-05-02 11:13:59 -0700</bug_when>
    <thetext>Comment on attachment 91941
Avoid potential buffer underrun in WTFLog() and WTFLogVerbose()

View in context: https://bugs.webkit.org/attachment.cgi?id=91941&amp;action=review

&gt; Source/JavaScriptCore/ChangeLog:5
&gt; +        Avoid potential buffer underrun in WTFLog() and WTFLogVerbose()

I think it&apos;s a buffer overrun, not underrun - &lt;http://en.wikipedia.org/wiki/Buffer_underrun&gt;.

&gt; Source/JavaScriptCore/wtf/Assertions.cpp:277
&gt; +    if (!format)
&gt; +        return;

I&apos;m not sure if this is a good time to make this check after calling vprintf_stderr_common. Or if it&apos;s really necessary - crashing on null ptr access if fairly safe, even if we were guarding against malicious input, which we aren&apos;t really.

&gt; Source/JavaScriptCore/wtf/Assertions.cpp:279
&gt; +    size_t formatLen = strlen(format);

Please don&apos;t abbreviate.

&gt; Source/JavaScriptCore/wtf/Assertions.cpp:294
&gt; +    if (!format) {

Same comment about necessity of the check.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>396494</commentid>
    <comment_count>3</comment_count>
    <who name="Jeff Miller">jeffm</who>
    <bug_when>2011-05-02 11:17:41 -0700</bug_when>
    <thetext>(In reply to comment #2)
&gt; (From update of attachment 91941 [details])
&gt; View in context: https://bugs.webkit.org/attachment.cgi?id=91941&amp;action=review
&gt; 
&gt; &gt; Source/JavaScriptCore/ChangeLog:5
&gt; &gt; +        Avoid potential buffer underrun in WTFLog() and WTFLogVerbose()
&gt; 
&gt; I think it&apos;s a buffer overrun, not underrun - &lt;http://en.wikipedia.org/wiki/Buffer_underrun&gt;.

Heh, actually according to that article it&apos;s always a buffer overflow when talking about memory.

&gt; 
&gt; &gt; Source/JavaScriptCore/wtf/Assertions.cpp:277
&gt; &gt; +    if (!format)
&gt; &gt; +        return;
&gt; 
&gt; I&apos;m not sure if this is a good time to make this check after calling vprintf_stderr_common. Or if it&apos;s really necessary - crashing on null ptr access if fairly safe, even if we were guarding against malicious input, which we aren&apos;t really.

OK, I&apos;ll remove the check.

&gt; 
&gt; &gt; Source/JavaScriptCore/wtf/Assertions.cpp:279
&gt; &gt; +    size_t formatLen = strlen(format);
&gt; 
&gt; Please don&apos;t abbreviate.

Changed to formatLength.

&gt; 
&gt; &gt; Source/JavaScriptCore/wtf/Assertions.cpp:294
&gt; &gt; +    if (!format) {
&gt; 
&gt; Same comment about necessity of the check.

Also removed this check.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>396497</commentid>
    <comment_count>4</comment_count>
    <who name="Jeff Miller">jeffm</who>
    <bug_when>2011-05-02 11:20:47 -0700</bug_when>
    <thetext>Landed http://trac.webkit.org/changeset/85496</thetext>
  </long_desc>
      
          <attachment
              isobsolete="0"
              ispatch="1"
              isprivate="0"
          >
            <attachid>91941</attachid>
            <date>2011-05-02 11:07:47 -0700</date>
            <delta_ts>2011-05-02 11:13:58 -0700</delta_ts>
            <desc>Avoid potential buffer underrun in WTFLog() and WTFLogVerbose()</desc>
            <filename>buffer-underrun.patch</filename>
            <type>text/plain</type>
            <size>1724</size>
            <attacher name="Jeff Miller">jeffm</attacher>
            
              <data encoding="base64">SW5kZXg6IFNvdXJjZS9KYXZhU2NyaXB0Q29yZS9DaGFuZ2VMb2cKPT09PT09PT09PT09PT09PT09
PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PQotLS0gU291
cmNlL0phdmFTY3JpcHRDb3JlL0NoYW5nZUxvZwkocmV2aXNpb24gODU0OTIpCisrKyBTb3VyY2Uv
SmF2YVNjcmlwdENvcmUvQ2hhbmdlTG9nCSh3b3JraW5nIGNvcHkpCkBAIC0xLDMgKzEsMTIgQEAK
KzIwMTEtMDUtMDIgIEplZmYgTWlsbGVyICA8amVmZm1AYXBwbGUuY29tPgorCisgICAgICAgIFJl
dmlld2VkIGJ5IE5PQk9EWSAoT09QUyEpLgorCisgICAgICAgIEF2b2lk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Bz
dHJsZW4oZm9ybWF0KTsKKyAgICBpZiAoZm9ybWF0TGVuICYmIGZvcm1hdFtmb3JtYXRMZW4gLSAx
XSAhPSAnXG4nKQogICAgICAgICBwcmludGZfc3RkZXJyX2NvbW1vbigiXG4iKTsKIH0KIApAQCAt
Mjg1LDggKzI5MCwxNiBAQCB2b2lkIFdURkxvZ1ZlcmJvc2UoY29uc3QgY2hhciogZmlsZSwgaW50
CiAgICAgdmFfc3RhcnQoYXJncywgZm9ybWF0KTsKICAgICB2cHJpbnRmX3N0ZGVycl9jb21tb24o
Zm9ybWF0LCBhcmdzKTsKICAgICB2YV9lbmQoYXJncyk7Ci0gICAgaWYgKGZvcm1hdFtzdHJsZW4o
Zm9ybWF0KSAtIDFdICE9ICdcbicpCisKKyAgICBpZiAoIWZvcm1hdCkgeworICAgICAgICBwcmlu
dENhbGxTaXRlKGZpbGUsIGxpbmUsIGZ1bmN0aW9uKTsKKyAgICAgICAgcmV0dXJuOworICAgIH0K
KyAgICAKKyAgICBzaXplX3QgZm9ybWF0TGVuID0gc3RybGVuKGZvcm1hdCk7CisgICAgaWYgKGZv
cm1hdExlbiAmJiBmb3JtYXRbZm9ybWF0TGVuIC0gMV0gIT0gJ1xuJykKICAgICAgICAgcHJpbnRm
X3N0ZGVycl9jb21tb24oIlxuIik7CisKICAgICBwcmludENhbGxTaXRlKGZpbGUsIGxpbmUsIGZ1
bmN0aW9uKTsKIH0KIAo=
</data>
<flag name="review"
          id="84848"
          type_id="1"
          status="+"
          setter="ap"
    />
          </attachment>
      

    </bug>

</bugzilla>