diff options
author | Carl Eugen Hoyos <cehoyos@ag.or.at> | 2015-05-16 23:32:56 +0200 |
---|---|---|
committer | Carl Eugen Hoyos <cehoyos@ag.or.at> | 2015-05-17 02:08:58 +0200 |
commit | 2608f11863918c7d82c3cb8928f6224d67e83bf1 (patch) | |
tree | 1c03eecc6c2868e19867866aeacbe0827ae49dc5 /libavformat/wavenc.c | |
parent | 101f26e758001dac564a8f1726c74cdde75ed8d1 (diff) | |
download | ffmpeg-2608f11863918c7d82c3cb8928f6224d67e83bf1.tar.gz |
lavf/wav: Print an error if files >4G are written.
Additionally, don't write an incorrect shorter size for such files.
Fixes part of ticket #4543.
Diffstat (limited to 'libavformat/wavenc.c')
-rw-r--r-- | libavformat/wavenc.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/libavformat/wavenc.c b/libavformat/wavenc.c index 74b5d56f84..f89c91e8c7 100644 --- a/libavformat/wavenc.c +++ b/libavformat/wavenc.c @@ -425,7 +425,7 @@ static int wav_write_trailer(AVFormatContext *s) avio_flush(pb); if (s->pb->seekable) { - if (wav->write_peak != 2) { + if (wav->write_peak != 2 && avio_tell(pb) - wav->data < UINT32_MAX) { ff_end_tag(pb, wav->data); avio_flush(pb); } @@ -440,12 +440,16 @@ static int wav_write_trailer(AVFormatContext *s) data_size = file_size - wav->data; if (wav->rf64 == RF64_ALWAYS || (wav->rf64 == RF64_AUTO && file_size - 8 > UINT32_MAX)) { rf64 = 1; - } else { + } else if (file_size - 8 <= UINT32_MAX) { avio_seek(pb, 4, SEEK_SET); avio_wl32(pb, (uint32_t)(file_size - 8)); avio_seek(pb, file_size, SEEK_SET); avio_flush(pb); + } else { + av_log(s, AV_LOG_ERROR, + "Filesize %"PRId64" invalid for wav, output file will be broken\n", + file_size); } number_of_samples = av_rescale(wav->maxpts - wav->minpts + wav->last_duration, |