[FFmpeg-cvslog] avformat/cafenc: Fix potential integer overflow

Andreas Rheinhardt git at videolan.org
Wed Jan 12 02:50:58 EET 2022


ffmpeg | branch: release/4.4 | Andreas Rheinhardt <andreas.rheinhardt at outlook.com> | Wed Sep 22 07:21:05 2021 +0200| [71eee0d4dc55356ce4127908f0d5f6411dc71c6d] | committer: Andreas Rheinhardt

avformat/cafenc: Fix potential integer overflow

(As long as avio_write() only accepts an int, it makes no sense
to try to support sizes that don't fit into an int.)

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt at outlook.com>
(cherry picked from commit 42fe438482dd0f1f59d86e27a88a616ad966706b)

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=71eee0d4dc55356ce4127908f0d5f6411dc71c6d
---

 libavformat/cafenc.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/libavformat/cafenc.c b/libavformat/cafenc.c
index 7e44797a52..16abf02162 100644
--- a/libavformat/cafenc.c
+++ b/libavformat/cafenc.c
@@ -213,7 +213,7 @@ static int caf_write_packet(AVFormatContext *s, AVPacket *pkt)
     avio_write(s->pb, pkt->data, pkt->size);
     if (!s->streams[0]->codecpar->block_align) {
         void *pkt_sizes = caf->pkt_sizes;
-        int i, alloc_size = caf->size_entries_used + 5;
+        int i, alloc_size = caf->size_entries_used + 5U;
         if (alloc_size < 0) {
             caf->pkt_sizes = NULL;
         } else {
@@ -250,7 +250,7 @@ static int caf_write_trailer(AVFormatContext *s)
         avio_seek(pb, file_size, SEEK_SET);
         if (!par->block_align) {
             ffio_wfourcc(pb, "pakt");
-            avio_wb64(pb, caf->size_entries_used + 24);
+            avio_wb64(pb, caf->size_entries_used + 24U);
             avio_wb64(pb, caf->packets); ///< mNumberPackets
             avio_wb64(pb, caf->packets * samples_per_packet(par->codec_id, par->channels, par->block_align)); ///< mNumberValidFrames
             avio_wb32(pb, 0); ///< mPrimingFrames



More information about the ffmpeg-cvslog mailing list