Skip to content

Commit

Permalink
Fix the bug that config->env is greater than ulong_max when units…
Browse files Browse the repository at this point in the history
…->val=1

Signed-off-by: Mauro Carvalho Chehab <[email protected]>
  • Loading branch information
zhuofeng authored and mchehab committed Nov 18, 2024
1 parent 8b53632 commit 683feac
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions ras-page-isolation.c
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,17 @@ static void parse_isolation_env(struct isolation *config)
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;
Expand Down

0 comments on commit 683feac

Please sign in to comment.