]> git.sesse.net Git - ffmpeg/commit
avformat/hls: Don't strdup non-null-terminated string
authorAndreas Rheinhardt <andreas.rheinhardt@gmail.com>
Tue, 3 Mar 2020 02:41:13 +0000 (03:41 +0100)
committerAndreas Rheinhardt <andreas.rheinhardt@gmail.com>
Tue, 24 Mar 2020 20:22:15 +0000 (21:22 +0100)
commit9dfc409e6b18d2984bdd5f041413173549e0fdd5
tree2753bc4c56e098bb58e2aa3b65cc34ade2a00e1f
parent65e8f6dd9b96df410233e80ad108e5ce57d54eae
avformat/hls: Don't strdup non-null-terminated string

If an URI indicated that the data protocol was in use, it would be
copied into a temporary buffer via strncpy(dst, src, strlen(src)),
thereby ensuring that the trailing \0 would not be copied, despite dst
being uninitialized. dst would then be av_strdup'ed, leading to
potential segfaults.

The solution to this is simple: Don't copy the URI in the temporary
buffer at all, instead av_strdup it directly.

This fixes a -Wstringop-truncation warning emitted by GCC 9.2.

Reviewed-by: Steven Liu <lq@chinaffmpeg.org>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
libavformat/hls.c