Skip to content

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

Open
arfa-21 wants to merge 1 commit into
sippy:masterfrom
arfa-21:eaud-gsm-whole-frames
Open

arfa-21 wants to merge 1 commit 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.

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.

1 participant