diff options
author | Mike Melanson <mike@multimedia.cx> | 2008-01-09 00:29:49 +0000 |
---|---|---|
committer | Mike Melanson <mike@multimedia.cx> | 2008-01-09 00:29:49 +0000 |
commit | 90527811d7db0da5d770235261c4b718b0869a99 (patch) | |
tree | d3ad3880599ef304ea472c9168c7ffba480f1fad /tools | |
parent | f34b221bd2bffc18e9d383b3e159a03b411818e9 (diff) | |
download | ffmpeg-90527811d7db0da5d770235261c4b718b0869a99.tar.gz |
Error checking: make sure that there are 3 parameters and that the
file open operation succeeds.
Originally committed as revision 11479 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'tools')
-rw-r--r-- | tools/trasher.c | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/tools/trasher.c b/tools/trasher.c index cc9f368fb4..60a2753114 100644 --- a/tools/trasher.c +++ b/tools/trasher.c @@ -6,10 +6,21 @@ int main(int argc, char** argv) { - FILE *f= fopen(argv[1], "rb+"); - int count= atoi(argv[2]); - int maxburst= atoi(argv[3]); - int length; + FILE *f; + int count, maxburst, length; + + if (argc < 4){ + printf("USAGE: trasher <filename> <count> <maxburst>\n"); + return 1; + } + + f= fopen(argv[1], "rb+"); + if (!f){ + perror(argv[1]); + return 2; + } + count= atoi(argv[2]); + maxburst= atoi(argv[3]); srand (time (0)); |