mirror of https://git.ffmpeg.org/ffmpeg.git
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>
This commit is contained in:
parent
2882286a08
commit
3022f74874
|
@ -356,25 +356,19 @@ static int argo_asf_write_header(AVFormatContext *s)
|
||||||
.num_chunks = 1,
|
.num_chunks = 1,
|
||||||
.chunk_offset = ASF_FILE_HEADER_SIZE
|
.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
|
* If the user specified a name, use it as is. Otherwise take the
|
||||||
* basename and lop off the extension (if any).
|
* basename and lop off the extension (if any).
|
||||||
*/
|
*/
|
||||||
if (ctx->name) {
|
if (name || !(end = strrchr((name = av_basename(s->url)), '.'))) {
|
||||||
strncpy(fhdr.name, ctx->name, sizeof(fhdr.name));
|
len = strlen(name);
|
||||||
} else {
|
} else {
|
||||||
const char *start = av_basename(s->url);
|
len = end - name;
|
||||||
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)));
|
|
||||||
}
|
}
|
||||||
|
memcpy(fhdr.name, name, FFMIN(len, sizeof(fhdr.name)));
|
||||||
|
|
||||||
chdr.num_blocks = 0;
|
chdr.num_blocks = 0;
|
||||||
chdr.num_samples = ASF_SAMPLE_COUNT;
|
chdr.num_samples = ASF_SAMPLE_COUNT;
|
||||||
|
|
Loading…
Reference in New Issue