From 7af2bc66079a0d427946e10ec7869fa042a6ae8a Mon Sep 17 00:00:00 2001 From: wm4 Date: Sun, 24 Feb 2013 21:05:59 +0100 Subject: options: reject nan, inf, 0:0, etc. for float options Same for time values. --- core/m_option.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'core') diff --git a/core/m_option.c b/core/m_option.c index 883ecd70a0..507d6cc2c7 100644 --- a/core/m_option.c +++ b/core/m_option.c @@ -522,6 +522,10 @@ static int clamp_double(const m_option_t *opt, void *val) v = opt->min; r = M_OPT_OUT_OF_RANGE; } + if (!isfinite(v)) { + v = opt->min; + r = M_OPT_OUT_OF_RANGE; + } VAL(val) = v; return r; } @@ -562,6 +566,13 @@ static int parse_double(const m_option_t *opt, struct bstr name, return M_OPT_OUT_OF_RANGE; } + if (!isfinite(tmp_float)) { + mp_msg(MSGT_CFGPARSER, MSGL_ERR, + "The %.*s option must be a finite number: %.*s\n", + BSTR_P(name), BSTR_P(param)); + return M_OPT_OUT_OF_RANGE; + } + if (dst) VAL(dst) = tmp_float; return 1; @@ -1532,6 +1543,8 @@ static int parse_timestring(struct bstr str, double *time, char endchar) return 0; /* unsupported time format */ if (len < str.len && str.start[len] != endchar) return 0; /* invalid extra characters at the end */ + if (!isfinite(*time)) + return 0; return len; } -- cgit v1.2.3