Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix parse param bug and set default when overflow #186

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

guodashun
Copy link

  1. In this patch, we check if the value is overflow before parsing the value with its unit. we replaced sscanf with strtoul cause the strtoul has clear errno ERANGE for overflow case.
  2. In this patch, we deleted the wrong logic unit_matched=0. When we set the param with a high level unit (e.g. PAGE_CE_THRESHOLD=1m), the real value we expect is 1000000(1*1000*1000), but now we only match the unit 'm' and multiply 1000 once, so the value we get is 1000 rather than 1000000. In this patch we fix the bug.
  3. When the value is overflow, the sscanf will produce Undefined Behavior (https://man7.org/linux/man-pages/man3/sscanf.3.html#BUGS). The final value after being truncated is confusing. So in this patch we will set to default value when the value is overflow.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant