[vlc-devel] [PATCH 2/2] rtp: fix stringop-truncation warning
Alexandre Janniaux
ajanni at videolabs.io
Thu Oct 3 23:22:36 CEST 2019
Hi,
Ping for the second patch, the first one has been discarded.
If needed, I can send a new standalone version.
Regards,
--
Alexandre Janniaux
Videolabs
On Thu, Sep 05, 2019 at 07:43:46PM +0200, Alexandre Janniaux wrote:
> 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