Skip to content

Commit

Permalink
options: reduce max delay to INT_MAX/1000
Browse files Browse the repository at this point in the history
avoids potential multiplication overflow when the seconds are converted
into milliseconds.
  • Loading branch information
N-R-K committed May 31, 2023
1 parent a57459c commit ce8e7f7
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/options.c
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,8 @@ void optionsParse(int argc, char *argv[])
opt.delaySelection = *optarg == 'b';
if (opt.delaySelection)
++optarg;
opt.delay = optionsParseNum(optarg, 0, INT_MAX, &errmsg);
/* NOTE: div 1000 so that converting to milliseconds doesn't overflow */
opt.delay = optionsParseNum(optarg, 0, INT_MAX/1000, &errmsg);
if (errmsg) {
errx(EXIT_FAILURE, "option --delay: '%s' is %s", optarg,
errmsg);
Expand Down

0 comments on commit ce8e7f7

Please sign in to comment.