Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(300)

Unified Diff: spdy/spdy_test.go

Issue 6786055: code review 6786055: net/spdy: handle corrupted zlib data on read
Patch Set: diff -r af69687727e7 https://code.google.com/p/go.net Created 13 years ago
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « spdy/read.go ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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)
+ }
+ }
+}
« no previous file with comments | « spdy/read.go ('k') | no next file » | no next file with comments »

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b