MCPcopy
hub / github.com/tailscale/tailscale / TestMapFrameSizeTooLarge

Function TestMapFrameSizeTooLarge

control/tsp/map_test.go:316–332  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

314// a frame larger than the configured cap is rejected before any payload
315// bytes are read from the stream.
316func 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.

Callers

nothing calls this directly

Calls 8

WriteMethod · 0.95
newTestPipelineFunction · 0.85
BytesMethod · 0.80
FatalMethod · 0.65
ErrorMethod · 0.65
ErrorfMethod · 0.65
DecodeMethod · 0.45
ContainsMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…