[bTSstream-devel] [Git][videolan/bitstream][master] 2 commits: ietf/rtp: add rtp_get_payload_offset helper
Christophe Massiot (@cmassiot)
gitlab at videolan.org
Mon Oct 26 11:02:59 UTC 2026
Christophe Massiot pushed to branch master at VideoLAN / bitstream
Commits:
b4cec5dd by Marton Balint at 2026-10-04T19:40:14+02:00
ietf/rtp: add rtp_get_payload_offset helper
Signed-off-by: Marton Balint <cus at passwd.hu>
- - - - -
e6704204 by Marton Balint at 2026-10-04T19:45:31+02:00
ietf/rtp: use rtp_get_payload_offset() in rtp_payload_size()
To avoid some pointer arithmetic which could be undefined behaviour in case of
a corrupt RTP packet.
Signed-off-by: Marton Balint <cus at passwd.hu>
- - - - -
1 changed file:
- ietf/rtp.h
Changes:
=====================================
ietf/rtp.h
=====================================
@@ -208,18 +208,23 @@ static inline uint16_t rtpx_get_length(const uint8_t *p_rtpx)
return (p_rtpx[2] << 8) | p_rtpx[3];
}
-static inline uint8_t *rtp_payload(uint8_t *p_rtp)
+static inline uint32_t rtp_get_payload_offset(uint8_t *p_rtp)
{
- unsigned int i_size = RTP_HEADER_SIZE;
+ uint32_t i_size = RTP_HEADER_SIZE;
i_size += 4 * rtp_get_cc(p_rtp);
if (rtp_check_extension(p_rtp))
i_size += 4 * (1 + rtpx_get_length(rtp_extension(p_rtp)));
- return p_rtp + i_size;
+ return i_size;
+}
+
+static inline uint8_t *rtp_payload(uint8_t *p_rtp)
+{
+ return p_rtp + rtp_get_payload_offset(p_rtp);
}
static inline size_t rtp_payload_size(uint8_t *p_rtp, size_t i_rtp_size)
{
- size_t i_payload_size = i_rtp_size - (rtp_payload(p_rtp) - p_rtp);
+ size_t i_payload_size = i_rtp_size - rtp_get_payload_offset(p_rtp);
uint8_t i_padding_size = 0;
if (rtp_check_padding(p_rtp))
i_padding_size = p_rtp[i_rtp_size - 1];
View it on GitLab: https://code.videolan.org/videolan/bitstream/-/compare/a3be36c2e916f94120a63621461f55e44a6d8eb9...e6704204fc0a53211614516aac25285e6cc6ac3f
--
View it on GitLab: https://code.videolan.org/videolan/bitstream/-/compare/a3be36c2e916f94120a63621461f55e44a6d8eb9...e6704204fc0a53211614516aac25285e6cc6ac3f
You're receiving this email because of your account on code.videolan.org. Manage all notifications: https://code.videolan.org/-/profile/notifications | Help: https://code.videolan.org/help
More information about the biTStream-devel
mailing list