diff options
author | Sébastien Helleu <flashcode@flashtux.org> | 2023-08-17 17:03:34 +0200 |
---|---|---|
committer | Sébastien Helleu <flashcode@flashtux.org> | 2023-08-17 17:03:34 +0200 |
commit | 274f5f9d53baea8a253700af1471a732cb2d9b45 (patch) | |
tree | c9685087c350f3984f9c04437ba3cb507457b741 /src/core | |
parent | d8bd0b7da857f257c3b24671be1a1c2c3e6e311a (diff) | |
download | weechat-274f5f9d53baea8a253700af1471a732cb2d9b45.zip |
core: fix integer overflow when setting integer option with `++N` or `--N`
Diffstat (limited to 'src/core')
-rw-r--r-- | src/core/wee-config-file.c | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/src/core/wee-config-file.c b/src/core/wee-config-file.c index f34901320..e5cb1ceb2 100644 --- a/src/core/wee-config-file.c +++ b/src/core/wee-config-file.c @@ -1491,22 +1491,22 @@ config_file_option_set (struct t_config_option *option, const char *value, { error = NULL; number = strtol (value + 2, &error, 10); - if (error && !error[0]) + if (error && !error[0] + && (long)old_value + number <= (long)(option->max)) { value_int = old_value + number; - if (value_int <= option->max) - new_value_ok = 1; + new_value_ok = 1; } } else if (strncmp (value, "--", 2) == 0) { error = NULL; number = strtol (value + 2, &error, 10); - if (error && !error[0]) + if (error && !error[0] + && (long)old_value - number >= (long)(option->min)) { value_int = old_value - number; - if (value_int >= option->min) - new_value_ok = 1; + new_value_ok = 1; } } else |