[vlc-devel] [PATCH 2/2] rtp: fix stringop-truncation warning
Thomas Guillem
thomas at gllm.fr
Mon Oct 7 09:49:12 CEST 2019
Merged thanks,
On Mon, Oct 7, 2019, at 08:43, Steve Lhomme wrote:
> LGTM, although I'd use sizeof(i_ts_init)
Sorry, just saw you remark about sizeof(i_ts_init).
Personally I don't have any preferences.
>
> On 2019-10-03 23:22, Alexandre Janniaux wrote:
> > 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
> >>
> > _______________________________________________
> > vlc-devel mailing list
> > To unsubscribe or modify your subscription options:
> > https://mailman.videolan.org/listinfo/vlc-devel
> >
> _______________________________________________
> vlc-devel mailing list
> To unsubscribe or modify your subscription options:
> https://mailman.videolan.org/listinfo/vlc-devel
More information about the vlc-devel
mailing list