1
0
mirror of https://github.com/weechat/weechat.git synced 2026-06-29 22:36:38 +02:00

core: fix integer overflow when setting integer option with ++N or --N

This commit is contained in:
Sébastien Helleu
2023-08-17 17:03:34 +02:00
parent d8bd0b7da8
commit 274f5f9d53
2 changed files with 7 additions and 6 deletions
+1
View File
@@ -34,6 +34,7 @@ New features::
Bug fixes::
* core: fix integer overflow when setting integer option with `++N` or `--N`
* core: fix cursor position after `/plugin list -i` or `/plugin list -il`
* core: display focus hashtable for debug even if no key is matching
* fset: remove extra spaces between min and max values when second format is used
+6 -6
View File
@@ -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