FAQ
Reviewers: mikio,

Message:
Hello mikioh.mikioh@gmail.com (cc: golang-dev@googlegroups.com,
rsc@golang.org),

I'd like you to review this change to
https://code.google.com/p/go.net


Description:
net/spdy: handle corrupted zlib data on read

Please review this at http://codereview.appspot.com/6786055/

Affected files:
M spdy/read.go
M spdy/spdy_test.go


Index: spdy/read.go
===================================================================
--- a/spdy/read.go
+++ b/spdy/read.go
@@ -200,7 +200,10 @@

reader := f.r
if !f.headerCompressionDisabled {
- f.uncorkHeaderDecompressor(int64(h.length - 10))
+ err := f.uncorkHeaderDecompressor(int64(h.length - 10))
+ if err != nil {
+ return err
+ }
reader = f.headerDecompressor
}

@@ -234,7 +237,10 @@
}
reader := f.r
if !f.headerCompressionDisabled {
- f.uncorkHeaderDecompressor(int64(h.length - 6))
+ err := f.uncorkHeaderDecompressor(int64(h.length - 6))
+ if err != nil {
+ return err
+ }
reader = f.headerDecompressor
}
frame.Headers, err = parseHeaderValueBlock(reader, frame.StreamId)
@@ -267,7 +273,10 @@
}
reader := f.r
if !f.headerCompressionDisabled {
- f.uncorkHeaderDecompressor(int64(h.length - 6))
+ err := f.uncorkHeaderDecompressor(int64(h.length - 6))
+ if err != nil {
+ return err
+ }
reader = f.headerDecompressor
}
frame.Headers, err = parseHeaderValueBlock(reader, frame.StreamId)
Index: spdy/spdy_test.go
===================================================================
--- a/spdy/spdy_test.go
+++ b/spdy/spdy_test.go
@@ -6,6 +6,8 @@

import (
"bytes"
+ "compress/zlib"
+ "encoding/base64"
"io"
"net/http"
"reflect"
@@ -495,3 +497,28 @@
t.Fatal("got: ", *parsedSynStreamFrame, "\nwant: ", synStreamFrame)
}
}
+
+func TestReadMalformedZlibHeader(t *testing.T) {
+ // These were constructed by corrupting the first byte of the zlib
+ // header after writing.
+ malformedStructs := map[string]string{
+ "SynStreamFrame": "gAIAAQAAABgAAAACAAAAAAAAF/nfolGyYmAAAAAA//8=",
+ "SynReplyFrame": "gAIAAgAAABQAAAACAAAX+d+iUbJiYAAAAAD//w==",
+ "HeadersFrame": "gAIACAAAABQAAAACAAAX+d+iUbJiYAAAAAD//w==",
+ }
+ for name, bad := range malformedStructs {
+ b, err := base64.StdEncoding.DecodeString(bad)
+ if err != nil {
+ t.Errorf("Unable to decode base64 encoded frame %s: %v", name, err)
+ }
+ buf := bytes.NewBuffer(b)
+ reader, err := NewFramer(buf, buf)
+ if err != nil {
+ t.Fatalf("NewFramer: %v", err)
+ }
+ _, err = reader.ReadFrame()
+ if err != zlib.ErrHeader {
+ t.Errorf("Frame %s, expected: %#v, actual: %#v", name, zlib.ErrHeader,
err)
+ }
+ }
+}

Search Discussions

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupgolang-dev @
categoriesgo
postedOct 27, '12 at 7:38p
activeOct 30, '12 at 6:08a
posts4
users3
websitegolang.org

3 users in discussion

Jeff: 2 posts Mikioh Mikioh: 1 post Agl: 1 post

People

Translate

site design / logo © 2021 Grokbase