diff options
author | Andreas Rheinhardt <andreas.rheinhardt@outlook.com> | 2021-09-26 04:07:30 +0200 |
---|---|---|
committer | Andreas Rheinhardt <andreas.rheinhardt@outlook.com> | 2021-09-26 08:51:41 +0200 |
commit | 3022f7487474ebb2812ae5e05b4be9b40431c20e (patch) | |
tree | 8074713201c141fddc813a4d81a5dc9d67cb20d0 | |
parent | 2882286a08c20fbb50bb55e16c82cbe6fdbfd565 (diff) | |
download | ffmpeg-3022f7487474ebb2812ae5e05b4be9b40431c20e.tar.gz |
avformat/argo_asf: Use memcpy to copy string without its NUL
This avoids a -Wstringop-truncation warning from GCC which takes
issue with the fact that the destination might not be NUL-terminated.
Reviewed-by: Zane van Iperen <zane@zanevaniperen.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
-rw-r--r-- | libavformat/argo_asf.c | 18 |
1 files changed, 6 insertions, 12 deletions
diff --git a/libavformat/argo_asf.c b/libavformat/argo_asf.c index 5adafb7230..7e759c7c0c 100644 --- a/libavformat/argo_asf.c +++ b/libavformat/argo_asf.c @@ -356,25 +356,19 @@ static int argo_asf_write_header(AVFormatContext *s) .num_chunks = 1, .chunk_offset = ASF_FILE_HEADER_SIZE }; + const char *name = ctx->name, *end; + size_t len; /* * If the user specified a name, use it as is. Otherwise take the * basename and lop off the extension (if any). */ - if (ctx->name) { - strncpy(fhdr.name, ctx->name, sizeof(fhdr.name)); + if (name || !(end = strrchr((name = av_basename(s->url)), '.'))) { + len = strlen(name); } else { - const char *start = av_basename(s->url); - const char *end = strrchr(start, '.'); - size_t len; - - if (end) - len = end - start; - else - len = strlen(start); - - memcpy(fhdr.name, start, FFMIN(len, sizeof(fhdr.name))); + len = end - name; } + memcpy(fhdr.name, name, FFMIN(len, sizeof(fhdr.name))); chdr.num_blocks = 0; chdr.num_samples = ASF_SAMPLE_COUNT; |