diff options
author | Stefano Sabatini <stefasab@gmail.com> | 2013-12-16 15:02:56 +0100 |
---|---|---|
committer | Stefano Sabatini <stefasab@gmail.com> | 2013-12-26 11:35:27 +0100 |
commit | 55f046be1193142536198957d1701d18881d3b7a (patch) | |
tree | 03ad2834b487613c5dfe419247d2b8c4646637ac /libavutil/opt.c | |
parent | 1575a96b3af5f5a769b043ff2342b6d17f954498 (diff) | |
download | ffmpeg-55f046be1193142536198957d1701d18881d3b7a.tar.gz |
lavu/opt: apply range checks also when setting format string value
Previously when setting a pixel/sample format as a string range checks
were not performed. This is consistent with the
av_opt_set_pixel/sample_fmt() interface.
Diffstat (limited to 'libavutil/opt.c')
-rw-r--r-- | libavutil/opt.c | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/libavutil/opt.c b/libavutil/opt.c index b625756760..0eaa8b5afe 100644 --- a/libavutil/opt.c +++ b/libavutil/opt.c @@ -298,7 +298,7 @@ static int set_string_color(void *obj, const AVOption *o, const char *val, uint8 static int set_string_fmt(void *obj, const AVOption *o, const char *val, uint8_t *dst, int fmt_nb, int ((*get_fmt)(const char *)), const char *desc) { - int fmt; + int fmt, min, max; if (!val || !strcmp(val, "none")) { fmt = -1; @@ -315,6 +315,16 @@ static int set_string_fmt(void *obj, const AVOption *o, const char *val, uint8_t } } + min = FFMAX(o->min, -1); + max = FFMIN(o->max, fmt_nb-1); + + if (fmt < min || fmt > max) { + av_log(obj, AV_LOG_ERROR, + "Value %d for parameter '%s' out of %s format range [%d - %d]\n", + fmt, o->name, desc, min, max); + return AVERROR(ERANGE); + } + *(int *)dst = fmt; return 0; } |