diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2005-01-12 00:59:42 +0000 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2005-01-12 00:59:42 +0000 |
commit | 2fc8ea249f325c2017137847bc1a565b77f40f11 (patch) | |
tree | 34f0783859f7637871650292705b657650f30800 /libavcodec/apiexample.c | |
parent | 0ecca7a49f8e254c12a3a1de048d738bfbb614c6 (diff) | |
download | ffmpeg-2fc8ea249f325c2017137847bc1a565b77f40f11.tar.gz |
dissallow sprintf
Originally committed as revision 3823 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavcodec/apiexample.c')
-rw-r--r-- | libavcodec/apiexample.c | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/libavcodec/apiexample.c b/libavcodec/apiexample.c index a2ee99dfc1..0c7617d853 100644 --- a/libavcodec/apiexample.c +++ b/libavcodec/apiexample.c @@ -415,7 +415,8 @@ int options_example(int argc, char* argv[]) AVCodec* codec = avcodec_find_encoder_by_name((argc > 1) ? argv[2] : "mpeg4"); const AVOption* c; AVCodecContext* avctx; - char* def = av_malloc(5000); +#define DEF_SIZE 5000 + char* def = av_malloc(DEF_SIZE); const char* col = ""; int i = 0; @@ -449,16 +450,16 @@ int options_example(int argc, char* argv[]) "unknown??", c->name); switch (t) { case FF_OPT_TYPE_BOOL: - i += sprintf(def + i, "%s%s=%s", + i += snprintf(def + i, DEF_SIZE-i, "%s%s=%s", col, c->name, c->defval != 0. ? "on" : "off"); break; case FF_OPT_TYPE_DOUBLE: - i += sprintf(def + i, "%s%s=%f", + i += snprintf(def + i, DEF_SIZE-i, "%s%s=%f", col, c->name, c->defval); break; case FF_OPT_TYPE_INT: - i += sprintf(def + i, "%s%s=%d", + i += snprintf(def + i, DEF_SIZE-i, "%s%s=%d", col, c->name, (int) c->defval); break; case FF_OPT_TYPE_STRING: @@ -467,7 +468,7 @@ int options_example(int argc, char* argv[]) char* f = strchr(d, ','); if (f) *f = 0; - i += sprintf(def + i, "%s%s=%s", + i += snprintf(def + i, DEF_SIZE-i, "%s%s=%s", col, c->name, d); av_free(d); } |