From: zhuofeng Date: Thu, 7 Dec 2023 06:37:50 +0000 (+0800) Subject: Fix the bug that `config->env` is greater than `ulong_max` when units->val=1 X-Git-Tag: v0.8.2~23 X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=683feacf378db0217b8ab421e0a694b0b68188c9;p=users%2Fmchehab%2Frasdaemon.git Fix the bug that `config->env` is greater than `ulong_max` when units->val=1 Signed-off-by: Mauro Carvalho Chehab --- diff --git a/ras-page-isolation.c b/ras-page-isolation.c index bb6b777..0ea36f6 100644 --- a/ras-page-isolation.c +++ b/ras-page-isolation.c @@ -157,6 +157,17 @@ parse: value *= units->val; if (tmp != 0 && value / tmp != units->val) config->overflow = true; + /** + * if units->val is 1, config->env is greater than ulong_max, so it is can strtoul + * if failed, the value is greater than ulong_max, set config->overflow = true + */ + if (units->val == 1) { + char *endptr; + unsigned long converted_value = strtoul(config->env, &endptr, 10); + if (errno == ERANGE || *endptr != '\0') + config->overflow = true; + } + unit_matched = 0; } } config->val = value;