Bug 30656

Summary: Fix calculation of length in WebSocketChannel.cpp
Product: WebKit Reporter: Fumitoshi Ukai <ukai>
Component: WebKit Misc.Assignee: Nobody <webkit-unassigned>
Status: RESOLVED FIXED    
Severity: Normal CC: commit-queue
Priority: P2    
Version: 528+ (Nightly build)   
Hardware: PC   
OS: All   
Attachments:
Description Flags
Fix calculation of length in WebSocketChannel.cpp none

Description Fumitoshi Ukai 2009-10-21 18:42:45 PDT
length = length * 128 + *p & 0x7f;
is wrong, because & is less precedence than +.
Comment 1 Fumitoshi Ukai 2009-10-21 18:45:59 PDT
Created attachment 41627 [details]
Fix calculation of length in WebSocketChannel.cpp
Comment 2 Alexey Proskuryakov 2009-10-21 23:57:04 PDT
Comment on attachment 41627 [details]
Fix calculation of length in WebSocketChannel.cpp

r=me

Will this covered by layout tests once we have them?
Comment 3 Fumitoshi Ukai 2009-10-22 00:05:46 PDT
(In reply to comment #2)
> (From update of attachment 41627 [details])
> r=me
> 
> Will this covered by layout tests once we have them?

Well, how about the following data sequence?
 0x81 0x81 0xCC 0x00 "unexpected data" 0xFF

It must skip 129 bytes after second 0x81, but wrong code gets 1 as length, so it would receive "unexpected data" unexpectedly.
Comment 4 WebKit Commit Bot 2009-10-22 00:11:31 PDT
Comment on attachment 41627 [details]
Fix calculation of length in WebSocketChannel.cpp

Clearing flags on attachment: 41627

Committed r49932: <http://trac.webkit.org/changeset/49932>
Comment 5 WebKit Commit Bot 2009-10-22 00:11:35 PDT
All reviewed patches have been landed.  Closing bug.
Comment 6 Fumitoshi Ukai 2009-10-22 01:32:12 PDT
(In reply to comment #3)
> (In reply to comment #2)
> > (From update of attachment 41627 [details] [details])
> > r=me
> > 
> > Will this covered by layout tests once we have them?
> 
> Well, how about the following data sequence?
>  0x81 0x81 0xCC 0x00 "unexpected data" 0xFF

Oops. should be 0x80 0x81 0x81 0xCC 0x00 "unexpected data" 0xFF

> 
> It must skip 129 bytes after second 0x81, but wrong code gets 1 as length, so
> it would receive "unexpected data" unexpectedly.