websocket: Check for slice size to avoid panic when classifying empty binary message (#1219)

* Check for slice size to avoid panic when classifying empty resp

* Simplify according to suggestion
This commit is contained in:
TaltaM
2023-06-09 01:24:33 +02:00
committed by GitHub
parent bb449c2085
commit a024ad53ae
2 changed files with 16 additions and 26 deletions

View File

@@ -908,7 +908,12 @@ func TestParseBinaryResponse(t *testing.T) {
t.Error(err3)
}
if !strings.EqualFold(string(resp2), "hello") {
t.Errorf("GZip conversion failed. Received: '%v', Expected: 'hello'", string(resp2))
t.Errorf("Deflate conversion failed. Received: '%v', Expected: 'hello'", string(resp2))
}
_, err4 := wc.parseBinaryResponse([]byte{})
if err4 == nil || err4.Error() != "unexpected EOF" {
t.Error("Expected error 'unexpected EOF'")
}
}