From dadfd73695cc511c43c4abfe4cde5043dd0c96df Mon Sep 17 00:00:00 2001 From: Dan Carpenter Date: Wed, 23 Aug 2017 16:03:32 +0300 Subject: [PATCH] ranges: add a sanity check in str_to_rl_helper() Ideally we wouldn't hit this... I'm not sure that we do. I wrote this code and then waffled about committing it because it sort of papers over bugs if new bugs are added. Anyway, if the DB has invalid data, just cap it at the type limits. Signed-off-by: Dan Carpenter --- smatch_ranges.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/smatch_ranges.c b/smatch_ranges.c index feb78bc9..c0d76997 100644 --- a/smatch_ranges.c +++ b/smatch_ranges.c @@ -406,6 +406,8 @@ static void str_to_rl_helper(struct expression *call, struct symbol *type, char if (*c == '(') c++; min = parse_val(0, call, type, c, &c); + if (!sval_fits(type, min)) + min = sval_type_min(type); max = min; if (*c == ')') c++; @@ -426,6 +428,8 @@ static void str_to_rl_helper(struct expression *call, struct symbol *type, char if (*c == '(') c++; max = parse_val(1, call, type, c, &c); + if (!sval_fits(type, max)) + max = sval_type_max(type); add_range_t(type, &rl_tmp, min, max); if (*c == ')') c++; -- 2.11.4.GIT