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 d0ff51f commit 3c89049
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 @@ -391,7 +391,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 3c89049

Please sign in to comment.