<?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>166475</bug_id>
          
          <creation_ts>2016-12-24 11:50:53 -0800</creation_ts>
          <short_desc>WebAssembly: parseVarUInt1 should take a uint32_t not a uint8_t</short_desc>
          <delta_ts>2016-12-24 13:52:42 -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>JavaScriptCore</component>
          <version>WebKit Nightly Build</version>
          <rep_platform>Unspecified</rep_platform>
          <op_sys>Unspecified</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>DUPLICATE</resolution>
          <dup_id>166448</dup_id>
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords>InRadar</keywords>
          <priority>P2</priority>
          <bug_severity>Normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Saam Barati">saam</reporter>
          <assigned_to name="Saam Barati">saam</assigned_to>
          <cc>benjamin</cc>
    
    <cc>fpizlo</cc>
    
    <cc>ggaren</cc>
    
    <cc>gskachkov</cc>
    
    <cc>jfbastien</cc>
    
    <cc>keith_miller</cc>
    
    <cc>mark.lam</cc>
    
    <cc>msaboff</cc>
    
    <cc>oliver</cc>
    
    <cc>ticaiolima</cc>
    
    <cc>webkit-bug-importer</cc>
    
    <cc>ysuzuki</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>1262669</commentid>
    <comment_count>0</comment_count>
    <who name="Saam Barati">saam</who>
    <bug_when>2016-12-24 11:50:53 -0800</bug_when>
    <thetext>We&apos;re loosing the top 3 bytes here, and that&apos;s bad. We loose them because we do static_cast&lt;uint32_t&gt;(uint8_t).
This is bad if say I parseVarUint1 and expect the result to be zero.
Right now, if somebody passed in:
0xffffff00
We&apos;d think it&apos;s zero because of how we drop the top 3 bytes. That&apos;s clearly wrong.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1262670</commentid>
    <comment_count>1</comment_count>
    <who name="Radar WebKit Bug Importer">webkit-bug-importer</who>
    <bug_when>2016-12-24 11:51:05 -0800</bug_when>
    <thetext>&lt;rdar://problem/29803564&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1262681</commentid>
    <comment_count>2</comment_count>
    <who name="Saam Barati">saam</who>
    <bug_when>2016-12-24 13:52:33 -0800</bug_when>
    <thetext>The bug is actually here:

```
232 template&lt;typename SuccessType&gt;
233 ALWAYS_INLINE bool Parser&lt;SuccessType&gt;::parseVarUInt1(uint8_t&amp; result)
234 {
235     uint32_t temp;
236     if (!parseVarUInt32(temp))
237         return false;
238     result = static_cast&lt;uint8_t&gt;(temp);
239     return temp &lt;= 1;
240 } 
```

We should check the value before the cast!
I&apos;ll just fix this as part of:
https://bugs.webkit.org/show_bug.cgi?id=166448</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1262682</commentid>
    <comment_count>3</comment_count>
    <who name="Saam Barati">saam</who>
    <bug_when>2016-12-24 13:52:42 -0800</bug_when>
    <thetext>

*** This bug has been marked as a duplicate of bug 166448 ***</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>