[Ffmpeg-devel] [PATCH] check with MAX_FILES in case buffer overflow

Limin Wang lance.lmwang
Mon Feb 26 03:44:58 CET 2007


Hi,

The patch try to fix the buffer overflow in case more than MAX_FILES input
files/output files/stream maps/meta maps. Please review it.

Thanks,
Limin
-------------- next part --------------
Index: ffmpeg.c
===================================================================
--- ffmpeg.c	(revision 8129)
+++ ffmpeg.c	(working copy)
@@ -2465,6 +2465,12 @@
     AVStreamMap *m;
     const char *p;
 
+    if( nb_stream_maps >= MAX_FILES ) {
+        fprintf(stderr, "The number of stream maps could not > %d \n",
+                MAX_FILES);
+        exit(1);
+    }
+
     p = arg;
     m = &stream_maps[nb_stream_maps++];
 
@@ -2490,6 +2496,12 @@
     AVMetaDataMap *m;
     const char *p;
 
+    if( nb_meta_data_maps >= MAX_FILES ) {
+        fprintf(stderr, "The number of meta data maps could not > %d \n",
+                MAX_FILES);
+        exit(1);
+    }
+
     p = arg;
     m = &meta_data_maps[nb_meta_data_maps++];
 
@@ -2527,6 +2539,12 @@
     int err, i, ret, rfps, rfps_base;
     int64_t timestamp;
 
+    if( nb_input_files >= MAX_FILES ) {
+        fprintf(stderr, "The number of input files could not > %d \n",
+                MAX_FILES);
+        exit(1);
+    }
+
     if (!strcmp(filename, "-"))
         filename = "pipe:";
 
@@ -3010,6 +3028,12 @@
     int use_video, use_audio, input_has_video, input_has_audio, i;
     AVFormatParameters params, *ap = ¶ms;
 
+    if( nb_output_files >= MAX_FILES ) {
+        fprintf(stderr, "The number of output files could not > %d \n",
+                MAX_FILES);
+        exit(1);
+    }
+
     if (!strcmp(filename, "-"))
         filename = "pipe:";
 



More information about the ffmpeg-devel mailing list