Repository navigation
fix(aac): reject ADTS payload lengths above 8184 bytes - #689
perfloop-agent wants to merge 2 commits into
Conversation
Signed-off-by: Perfloop Agent <[email protected]> Signed-off-by: Tomás Senart <[email protected]>
Signed-off-by: Perfloop Agent <[email protected]> Signed-off-by: Tomás Senart <[email protected]>
|
About the test: enumerating all 65,536 payload lengths at each of the 13 sample rates, about 850,000 encode and decode round trips, is very inefficient for a trivial limit, and not something I want in the test harness. Testing the boundary values covers it. A small table that accepts 0, a middle value and 8184 and rejects 8185 and 65535 says the same in a few lines. The round trip through As feedback for the tool, in case it helps to tune it: for a fixed limit like this, test the values at and next to the limit, plus a middle value if there is one, instead of every possible input. |
|
I'm fixing a bit more in another PR: |
… accept AAC Main NewADTSHeader now checks every value against its field in adts_fixed_header (ISO/IEC 14496-3:2019 Table 1.A.6): - channelConfig must be at most 7, since channel_configuration has 3 bits. Before, Encode silently wrote only the low 3 bits, so 13 became 5. - plLen must be at most 8184, since frame_length has 13 bits and includes the 7-byte header. Before, Encode wrapped larger values, so 8185 gave frame length 0. A valid AAC frame stays below this anyway: the decoder input buffer is 6144 bits per channel, so channel configurations 1-7 give at most 6144 bytes. - objectType may also be AAC Main, which the 2-bit profile field signals as 0 and which DecodeADTSHeader already returns as object type 1. HE-AAC is still rejected, since ADTS sends it as AAC-LC with implicit SBR signaling. TestNewADTSHeader tests each limit at its boundary values, plus a middle value, and decodes every accepted header again. This replaces PR #689, which checked only the payload length and tested all 65,536 lengths at each sample rate. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01EagxH7ENAVwUPJWTRiw1wQ
|
Thanks for the feedback @tobbee. |
aac.NewADTSHeadernow returns a nil header and an error for payload lengths above 8184 bytes. The seven-byte header and payload must fit in the thirteen-bit ADTS frame length. Previously, payload 8185 was accepted but encoded a frame length of zero.Lengths from 0 through 8184 remain accepted. The existing object-type and sample-rate checks keep their precedence, and direct
ADTSHeader.Encodebehavior is unchanged. The API comment and changelog document the constructor limit.The Go ADTS tests in
aacpass. The regression test in aac/adts_test.go enumerates everyuint16payload length with AAC-LC stereo at every supported sample rate. It checks rejection above the limit and exact wire lengths and decoded headers for accepted inputs, including payloads 0 and 8184. The existing tests cover sync offsets, CRC headers and frame lengths shorter than the header.This is a header-only check; it does not parse AAC payload contents or validate directly mutated headers.
Case and evidence
Made by Perfloop. Human sponsor: Tomás Senart. To ask for a change, comment or review in plain words. How Perfloop handles pull requests.