Skip to content

Stop GSM decoding at the last whole frame in decode_frame() - #192

Merged
sobomax merged 3 commits into
sippy:masterfrom
arfa-21:eaud-gsm-whole-frames
Nov 27, 2026
Merged

sobomax merged 3 commits into
sippy:masterfrom
arfa-21:eaud-gsm-whole-frames

Conversation

@arfa-21

@arfa-21 arfa-21 commented Nov 21, 2026

Copy link
Copy Markdown
Contributor

Repro: record a session where the peer sends RTP with PT 3 (GSM) and a payload that is not a multiple of 33 bytes, e.g. 34, then run extractaudio on it.
Cause: decode_frame() loops on ibytes > 0 with ibytes -= 33 on an unsigned int, so after the first frame it calls gsm_decode() on a 1 byte remainder and ibytes wraps. The loop then only stops on obytes_max: 25 frames at 8 kHz, about 800 bytes read past the packet into the rest of the mmap()ed recording or past its end, and 4000 ticks of garbage audio in place of 160. An ASan build of the GSM case reports a heap-buffer-overflow READ of size 33 in gsm_decode() for a 34 byte payload.
Fix: decode only while a whole frame is left, which is also how rtp_calc_samples() counts GSM (160 * (nbytes / 33)). Payloads that are a multiple of 33 bytes, including all packets in tests/extractaudio/call1_gsm, decode exactly as before.

arfa-21 and others added 3 commits November 26, 2026 17:11
Add corrupted_gsm, a copy of call1_gsm where every 7th packet carries one
extra trailing payload byte (34 byte payload), and the gsm_partial test
that decodes both recordings and requires identical audio, i.e. that the
partial trailing frame is ignored.

Fails without the decode_frame() fix (outputs differ from byte 1281).
@sobomax
sobomax force-pushed the eaud-gsm-whole-frames branch from df5cbab to 223fa9f Compare November 27, 2026 00:14
@sobomax
sobomax merged commit d26556d into sippy:master Nov 27, 2026
348 of 358 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants