TestMapFrameSizeTooLarge verifies that a 4-byte length prefix claiming a frame larger than the configured cap is rejected before any payload bytes are read from the stream.
(t *testing.T)
| 314 | // a frame larger than the configured cap is rejected before any payload |
| 315 | // bytes are read from the stream. |
| 316 | func TestMapFrameSizeTooLarge(t *testing.T) { |
| 317 | const max = 4 << 20 |
| 318 | var wire bytes.Buffer |
| 319 | var hdr [4]byte |
| 320 | binary.LittleEndian.PutUint32(hdr[:], (max + 1)) |
| 321 | wire.Write(hdr[:]) |
| 322 | |
| 323 | jdec := newTestPipeline(t, wire.Bytes(), max) |
| 324 | var resp tailcfg.MapResponse |
| 325 | err := jdec.Decode(&resp) |
| 326 | if err == nil { |
| 327 | t.Fatal("Decode: got nil error, want frame-too-large") |
| 328 | } |
| 329 | if !strings.Contains(err.Error(), "exceeds max") { |
| 330 | t.Errorf("Decode error = %q, want one containing %q", err, "exceeds max") |
| 331 | } |
| 332 | } |
| 333 | |
| 334 | // TestMapDecodedSizeTooLarge verifies that a small on-wire frame (well |
| 335 | // under the cap) which decompresses into a huge JSON payload is rejected. |
nothing calls this directly
no test coverage detected
searching dependent graphs…