srs/internal
winlin 41528168e4 Claude: RTMP: Add protocol unit-test suite and harden packet unmarshal.
Implements the Go RTMP stack unit-test plan (internal/rtmp), cross-referenced
to the C++ srs_utest_manual_protocol/protocol2/rtmp suites, and fixes the one
panic class the fuzz targets exposed.

Tests added (rtmp_test.go):
- TestReadMessageInterleavedMultiStream    interleaved multi-cid reassembly
- TestReadMessageLargeChunkStreamID        2-/3-byte cid full-message read
- TestProtocolWritePacketReadMessageRoundTrip  encoder<->decoder, 14 pkts x 4 sizes
- TestReadMessageTimestampDiscontinuity    backward/forward jump, 31-bit wrap
- TestReadWriteLargePayloadChunkBoundaries chunk-boundary stress
- TestGoldenWireBytes                       golden bytes for headers + controls
- FuzzReadMessage / FuzzDecodeMessage / FuzzPacketUnmarshal  untrusted-input fuzz
- TestPacketUnmarshalAdversarialInputs      resource-safety / truncation
- TestProtocolTransactionMapConcurrency     -race on the transaction map

Hardening (rtmp.go): the fuzz targets found that the variantCallPacket family
counted a stale optional-field default (CommandObject/Args pre-set to Null by a
New*Packet constructor) when the wire data was exhausted, so Size() overran the
caller's p = p[Size():] advance and panicked on truncated, untrusted input.
Reset those fields to nil before the presence check, and route the embedded
advances in CallPacket/CreateStreamResPacket/PublishPacket/PlayPacket through a
bounds-checked advanceBytes helper so any future Size()/consumed mismatch becomes
a clean error instead of a slice-out-of-range panic.

Verified: full proxy unit suite passes; TestProtocolTransactionMapConcurrency
clean under go test -race -count=3; all proxy E2E scripts pass.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-05-28 21:09:27 -04:00
..
bootstrap Proxy: Refactor for testability; add SRT/WHIP E2E and unit tests. v7.0.148 (#4675) 2026-05-17 12:09:07 -04:00
debug Proxy: Fix RTC/SRT reader leak, legacy WHEP unwrap, WHEP perf guide. v8.0.1 (#4676) 2026-05-17 21:13:21 -04:00
env Proxy: Refine logger and environment APIs. v7.0.146 (#4670) 2026-04-28 07:18:45 -04:00
errors Proxy: Modernize internal packages on stdlib and add unit tests. v7.0.145 (#4667) 2026-04-23 07:25:48 -04:00
lb Proxy: Refactor for testability; add SRT/WHIP E2E and unit tests. v7.0.148 (#4675) 2026-05-17 12:09:07 -04:00
logger Proxy: Refine logger and environment APIs. v7.0.146 (#4670) 2026-04-28 07:18:45 -04:00
proxy Proxy: Fix RTC/SRT reader leak, legacy WHEP unwrap, WHEP perf guide. v8.0.1 (#4676) 2026-05-17 21:13:21 -04:00
redisclient Proxy: Refactor for testability; add SRT/WHIP E2E and unit tests. v7.0.148 (#4675) 2026-05-17 12:09:07 -04:00
rtmp Claude: RTMP: Add protocol unit-test suite and harden packet unmarshal. 2026-05-28 21:09:27 -04:00
signal Proxy: Refactor for testability; add SRT/WHIP E2E and unit tests. v7.0.148 (#4675) 2026-05-17 12:09:07 -04:00
sync Proxy: Modernize internal packages on stdlib and add unit tests. v7.0.145 (#4667) 2026-04-23 07:25:48 -04:00
utils Proxy: Fix RTC/SRT reader leak, legacy WHEP unwrap, WHEP perf guide. v8.0.1 (#4676) 2026-05-17 21:13:21 -04:00
version Edge: Fix HTTP-FLV 404 and RTMP late-join missing sequence headers. v8.0.2 (#4678) 2026-05-19 10:53:30 -04:00