http://codereview.appspot.com/6374059/diff/1/src/pkg/encoding/gob/decode.go File src/pkg/encoding/gob/decode.go (left): http://codereview.appspot.com/6374059/diff/1/src/pkg/encoding/gob/decode.go#oldcode655 src/pkg/encoding/gob/decode.go:655: if nr > uint64(state.b.Len()) { I'm nervous about removing ...
12 years, 8 months ago
(2012-07-11 23:11:51 UTC)
#2
http://codereview.appspot.com/6374059/diff/1/src/pkg/encoding/gob/decode.go
File src/pkg/encoding/gob/decode.go (left):
http://codereview.appspot.com/6374059/diff/1/src/pkg/encoding/gob/decode.go#o...
src/pkg/encoding/gob/decode.go:655: if nr > uint64(state.b.Len()) {
I'm nervous about removing this. This was originally added as a DoS protection
mechanism to stop a message of only a few bytes causing this code to allocate
many GB.
I still don't understand what goes wrong here. If there's a type definition
after a slice then this condition still needs to hold, right? This function is
going to require at least nr bytes.
http://codereview.appspot.com/6374059/diff/1/src/pkg/encoding/gob/decode.go File src/pkg/encoding/gob/decode.go (left): http://codereview.appspot.com/6374059/diff/1/src/pkg/encoding/gob/decode.go#oldcode655 src/pkg/encoding/gob/decode.go:655: if nr > uint64(state.b.Len()) { you can be nervous ...
12 years, 8 months ago
(2012-07-11 23:35:45 UTC)
#3
http://codereview.appspot.com/6374059/diff/1/src/pkg/encoding/gob/decode.go
File src/pkg/encoding/gob/decode.go (left):
http://codereview.appspot.com/6374059/diff/1/src/pkg/encoding/gob/decode.go#o...
src/pkg/encoding/gob/decode.go:655: if nr > uint64(state.b.Len()) {
you can be nervous about removing it but the test is incorrect and that's what's
wrong. in the case in question, we have a slice of interfaces. the first element
of the slice defines a type, and each type definition is sent as a separate
message. thus the length being looked at here is the the length of the type
definition, not of the data that follows it as a separate length-delimited
message.
On Thu, Jul 12, 2012 at 9:35 AM, <r@golang.org> wrote: > you can be nervous ...
12 years, 8 months ago
(2012-07-11 23:41:09 UTC)
#4
On Thu, Jul 12, 2012 at 9:35 AM, <r@golang.org> wrote:
> you can be nervous about removing it but the test is incorrect and
> that's what's wrong. in the case in question, we have a slice of
> interfaces. the first element of the slice defines a type, and each type
> definition is sent as a separate message. thus the length being looked
> at here is the the length of the type definition, not of the data that
> follows it as a separate length-delimited message.
Aah, so can this check just be skipped for type definitions? And
perhaps we can have some sensible upper bound for them (say, 1 KB)?
On Jul 11, 2012, at 4:41 PM, David Symonds wrote: > On Thu, Jul 12, ...
12 years, 8 months ago
(2012-07-11 23:44:58 UTC)
#5
On Jul 11, 2012, at 4:41 PM, David Symonds wrote:
> On Thu, Jul 12, 2012 at 9:35 AM, <r@golang.org> wrote:
>
>> you can be nervous about removing it but the test is incorrect and
>> that's what's wrong. in the case in question, we have a slice of
>> interfaces. the first element of the slice defines a type, and each type
>> definition is sent as a separate message. thus the length being looked
>> at here is the the length of the type definition, not of the data that
>> follows it as a separate length-delimited message.
>
> Aah, so can this check just be skipped for type definitions? And
> perhaps we can have some sensible upper bound for them (say, 1 KB)?
We can't tell if there's a type definition embedded somewhere in this slice
element's encoding. In the original example, the type definition starts 6 bytes
into the element encoding.
-rob
*** Submitted as http://code.google.com/p/go/source/detail?r=d5754b3d9f44 *** encoding/gob: fix check for short input in slice decode R=golang-dev, ...
12 years, 8 months ago
(2012-07-12 17:23:58 UTC)
#8
Issue 6374059: code review 6374059: encoding/gob: fix check for short input in slice decode
(Closed)
Created 12 years, 8 months ago by r
Modified 12 years, 8 months ago
Reviewers:
Base URL:
Comments: 3