Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
 help / color / mirror / Atom feed
* [FFmpeg-devel] [PATCH] Fix issue when invalid nb_index_entries value is read - SPONSORED BY INA (Institut National de l'Audiovisuel)
@ 2023-03-08 15:55 Cédric Le Barz
  2023-03-08 22:05 ` Marton Balint
  0 siblings, 1 reply; 10+ messages in thread
From: Cédric Le Barz @ 2023-03-08 15:55 UTC (permalink / raw)
  To: ffmpeg-devel


Fix issue when invalid nb_index_entries value is read : in case of false 
nb_index_entries value, ffmpeg exit. This patch fix this problem.


Signed-off-by: Cedric Le Barz <clebarz@ektacom.com>
---
  ffmpeg/libavformat/mxfdec.c | 14 ++++++++++++--
  1 file changed, 12 insertions(+), 2 deletions(-)

diff --git a/ffmpeg/libavformat/mxfdec.c b/ffmpeg/libavformat/mxfdec.c
index 4530617..ffc8987 100644
--- a/ffmpeg/libavformat/mxfdec.c
+++ b/ffmpeg/libavformat/mxfdec.c
@@ -1221,8 +1221,18 @@ static int mxf_read_index_entry_array(AVIOContext 
*pb, MXFIndexTableSegment *seg
      }
       for (i = 0; i < segment->nb_index_entries; i++) {
-        if(avio_feof(pb))
-            return AVERROR_INVALIDDATA;
+
+        if(avio_feof(pb)) {
+            if (i == 0) {
+                return AVERROR_INVALIDDATA;
+            } else {
+                /* To be more robust to invalid nb_index_entries value,
+                   fix the index entry number according to read entries */
+                segment->nb_index_entries = i;
+                return 0;
+            }
+        }
+
          segment->temporal_offset_entries[i] = avio_r8(pb);
          avio_r8(pb);                                        /* 
KeyFrameOffset */
          segment->flag_entries[i] = avio_r8(pb);
-- 
2.34.1

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2023-03-26 21:06 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-03-08 15:55 [FFmpeg-devel] [PATCH] Fix issue when invalid nb_index_entries value is read - SPONSORED BY INA (Institut National de l'Audiovisuel) Cédric Le Barz
2023-03-08 22:05 ` Marton Balint
2023-03-16  9:45   ` Cédric Le Barz
2023-03-16 20:28     ` Marton Balint
2023-03-20 15:52       ` Cédric Le Barz
2023-03-20 20:03         ` Marton Balint
2023-03-24  9:13           ` Cédric Le Barz
2023-03-24 10:22             ` Cédric Le Barz
2023-03-26 21:06               ` Marton Balint
2023-03-16 13:33   ` Cédric Le Barz

Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \
		ffmpegdev@gitmailbox.com
	public-inbox-index ffmpegdev

Example config snippet for mirrors.


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git