X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=tools%2Fqt-faststart.c;h=eefeafdfac39229947f3d556772e80edfcb249af;hb=3fbc9bbb884da6a1fb331b1cb03945008ee36312;hp=e1bcebca93819d7035922137b54adfbc90b6e24d;hpb=e3d7269fc825443d2daed50c7b3382b4ffbd2bf1;p=ffmpeg diff --git a/tools/qt-faststart.c b/tools/qt-faststart.c index e1bcebca938..eefeafdfac3 100644 --- a/tools/qt-faststart.c +++ b/tools/qt-faststart.c @@ -8,7 +8,7 @@ * is in front of the data, thus facilitating network streaming. * * To compile this program, start from the base directory from which you - * are building FFmpeg and type: + * are building Libav and type: * make tools/qt-faststart * The qt-faststart program will be built in the tools/ directory. If you * do not build the program in this manner, correct results are not @@ -27,6 +27,7 @@ #include #include #include +#include #ifdef __MINGW32__ #define fseeko(x,y,z) fseeko64(x,y,z) @@ -83,7 +84,7 @@ int main(int argc, char *argv[]) uint64_t atom_offset = 0; uint64_t last_offset; unsigned char *moov_atom = NULL; - unsigned char *ftyp_atom = 0; + unsigned char *ftyp_atom = NULL; uint64_t moov_atom_size; uint64_t ftyp_atom_size = 0; uint64_t i, j; @@ -98,6 +99,11 @@ int main(int argc, char *argv[]) return 0; } + if (!strcmp(argv[1], argv[2])) { + fprintf(stderr, "input and output files need to be different\n"); + return 1; + } + infile = fopen(argv[1], "rb"); if (!infile) { perror(argv[1]); @@ -163,6 +169,12 @@ int main(int argc, char *argv[]) break; } atom_offset += atom_size; + + /* The atom header is 8 (or 16 bytes), if the atom size (which + * includes these 8 or 16 bytes) is less than that, we won't be + * able to continue scanning sensibly after this atom, so break. */ + if (atom_size < 8) + break; } if (atom_type != MOOV_ATOM) {