1
0
mirror of https://github.com/weechat/weechat.git synced 2026-06-26 21:06: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 77911680bb
commit 4eabcdf840
2 changed files with 7 additions and 6 deletions
+6 -6
View File
@@ -1527,22 +1527,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