mirror of
https://github.com/amadvance/snapraid.git
synced 2026-12-04 13:50:09 -05:00
Avoid undefined behaviour parsing double
This commit is contained in:
parent
1d2ab288d1
commit
8ee24aa26c
1 changed files with 6 additions and 2 deletions
|
|
@ -1100,13 +1100,17 @@ int snapraid_main(int argc, char* argv[])
|
||||||
plan100 = SCRUB_FULL;
|
plan100 = SCRUB_FULL;
|
||||||
} else {
|
} else {
|
||||||
double plan_double = strtod(optarg, &e);
|
double plan_double = strtod(optarg, &e);
|
||||||
plan100 = plan_double * 100;
|
if (!e || *e != 0
|
||||||
if (!e || *e || plan100 > 10000) {
|
|| !isfinite(plan_double)
|
||||||
|
|| plan_double < 0
|
||||||
|
|| plan_double > 100
|
||||||
|
) {
|
||||||
/* LCOV_EXCL_START */
|
/* LCOV_EXCL_START */
|
||||||
log_fatal(EUSER, "Invalid plan/percentage '%s'\n", optarg);
|
log_fatal(EUSER, "Invalid plan/percentage '%s'\n", optarg);
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
/* LCOV_EXCL_STOP */
|
/* LCOV_EXCL_STOP */
|
||||||
}
|
}
|
||||||
|
plan100 = plan_double * 100;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 'o' :
|
case 'o' :
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue