Skip to content

rtp: copy only the payload in rtp_recvfrom and terminate it - #842

Open
nabhan06 wants to merge 1 commit into
cisco:mainfrom
nabhan06:rtp-recvfrom-payload-copy
Open

nabhan06 wants to merge 1 commit into
cisco:mainfrom
nabhan06:rtp-recvfrom-payload-copy

Conversation

@nabhan06

Copy link
Copy Markdown

rtp_recvfrom() in test/rtp.c copies octets_recvd bytes out of message.body, but after srtp_unprotect() that count still includes the 12-byte RTP header, so it pulls in 12 bytes past the payload (the stripped tag plus whatever was left in the buffer) and never writes a terminator, while rtpw's receiver prints the 128-byte word buffer with %s. With rtpw running as -r -e (no auth), a single 128-byte datagram for SSRC 0xdeadbeef was enough for ASan to report a stack-buffer-overflow READ on word in a harness that calls rtp_recvfrom() the same way rtpw does. Copying only octets_recvd - RTP_HEADER_LEN bytes and null-terminating fixes it, and the terminator always fits because recvfrom() is already capped at *len; normal words still round-trip unchanged with conf+auth.

octets_recvd is the length of the whole unprotected packet, header
included, so copying that many bytes from message.body ran 12 bytes past
the payload and left msg without a terminator. rtpw prints the result
with %s and could read past its stack buffer.
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