[FFmpeg-cvslog] qt-faststart: check fseeko() return codes

Michael Niedermayer git at videolan.org
Mon Oct 22 22:56:53 CEST 2012


ffmpeg | branch: master | Michael Niedermayer <michaelni at gmx.at> | Mon Oct 22 22:42:51 2012 +0200| [0de41ead6f9034e0a834abe51028a02aee094990] | committer: Michael Niedermayer

qt-faststart: check fseeko() return codes

Fixes CID733725

Signed-off-by: Michael Niedermayer <michaelni at gmx.at>

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

 tools/qt-faststart.c |   24 ++++++++++++++++++------
 1 file changed, 18 insertions(+), 6 deletions(-)

diff --git a/tools/qt-faststart.c b/tools/qt-faststart.c
index 8af510f..80c5d4b 100644
--- a/tools/qt-faststart.c
+++ b/tools/qt-faststart.c
@@ -136,22 +136,27 @@ int main(int argc, char *argv[])
                        atom_size);
                 goto error_out;
             }
-            fseeko(infile, -ATOM_PREAMBLE_SIZE, SEEK_CUR);
-            if (fread(ftyp_atom, atom_size, 1, infile) != 1) {
+            if (   fseeko(infile, -ATOM_PREAMBLE_SIZE, SEEK_CUR)
+                || fread(ftyp_atom, atom_size, 1, infile) != 1) {
                 perror(argv[1]);
                 goto error_out;
             }
             start_offset = ftello(infile);
         } else {
+            int ret;
             /* 64-bit special case */
             if (atom_size == 1) {
                 if (fread(atom_bytes, ATOM_PREAMBLE_SIZE, 1, infile) != 1) {
                     break;
                 }
                 atom_size = BE_64(&atom_bytes[0]);
-                fseeko(infile, atom_size - ATOM_PREAMBLE_SIZE * 2, SEEK_CUR);
+                ret = fseeko(infile, atom_size - ATOM_PREAMBLE_SIZE * 2, SEEK_CUR);
             } else {
-                fseeko(infile, atom_size - ATOM_PREAMBLE_SIZE, SEEK_CUR);
+                ret = fseeko(infile, atom_size - ATOM_PREAMBLE_SIZE, SEEK_CUR);
+            }
+            if(ret) {
+                perror(argv[1]);
+                goto error_out;
             }
         }
         printf("%c%c%c%c %10"PRIu64" %"PRIu64"\n",
@@ -192,7 +197,10 @@ int main(int argc, char *argv[])
 
     /* moov atom was, in fact, the last atom in the chunk; load the whole
      * moov atom */
-    fseeko(infile, -atom_size, SEEK_END);
+    if (fseeko(infile, -atom_size, SEEK_END)) {
+        perror(argv[1]);
+        goto error_out;
+    }
     last_offset    = ftello(infile);
     moov_atom_size = atom_size;
     moov_atom      = malloc(moov_atom_size);
@@ -268,7 +276,11 @@ int main(int argc, char *argv[])
     }
 
     if (start_offset > 0) { /* seek after ftyp atom */
-        fseeko(infile, start_offset, SEEK_SET);
+        if (fseeko(infile, start_offset, SEEK_SET)) {
+            perror(argv[1]);
+            goto error_out;
+        }
+
         last_offset -= start_offset;
     }
 



More information about the ffmpeg-cvslog mailing list