[vlc-devel] [PATCH 2/2] rtp: fix stringop-truncation warning
Alexandre Janniaux
ajanni at videolabs.io
Thu Sep 5 19:43:46 CEST 2019
strncpy inserts a last null character, which prevents from copying 8
bytes correctly. Instead, zero the integer and reproduce strncpy
behaviour without the trailing \0.
---
modules/stream_out/rtp.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/modules/stream_out/rtp.c b/modules/stream_out/rtp.c
index 3341bde9c5..d4c7460477 100644
--- a/modules/stream_out/rtp.c
+++ b/modules/stream_out/rtp.c
@@ -1560,9 +1560,11 @@ static vlc_tick_t rtp_init_ts( const vod_media_t *p_media,
if (p_media == NULL || psz_vod_session == NULL)
return vlc_tick_now();
- uint64_t i_ts_init;
+ uint64_t i_ts_init = 0;
/* As per RFC 2326, session identifiers are at least 8 bytes long */
- strncpy((char *)&i_ts_init, psz_vod_session, sizeof(uint64_t));
+ size_t session_length = strlen(psz_vod_session);
+ memcpy(&i_ts_init, psz_vod_session, __MIN(session_length,
+ sizeof(uint64_t)));
i_ts_init ^= (uintptr_t)p_media;
/* Limit the timestamp to 48 bits, this is enough and allows us
* to stay away from overflows */
--
2.23.0
More information about the vlc-devel
mailing list