Skip to content

Commit

Permalink
Do proper error handling of strtonum
Browse files Browse the repository at this point in the history
Checking for an error string is the proper step.
Have an error string for consistency.
  • Loading branch information
RSilicon committed Jul 8, 2023
1 parent 7e8800f commit 704c937
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions ssh-add.c
Original file line number Diff line number Diff line change
Expand Up @@ -788,6 +788,7 @@ main(int argc, char **argv)
extern char *optarg;
extern int optind;
int agent_fd;
const char *errstr = NULL;
char *pkcs11provider = NULL, *skprovider = NULL;
char **dest_constraint_strings = NULL, **hostkey_files = NULL;
int r, i, ch, deleting = 0, ret = 0, key_only = 0, do_download = 0;
Expand Down Expand Up @@ -863,16 +864,16 @@ main(int argc, char **argv)
confirm = 1;
break;
case 'm':
minleft = (u_int)strtonum(optarg, 1, UINT_MAX, NULL);
if (minleft == 0) {
minleft = (u_int)strtonum(optarg, 1, UINT_MAX, &errstr);
if (errstr) {
usage();
ret = 1;
goto done;
}
break;
case 'M':
maxsign = (u_int)strtonum(optarg, 1, UINT_MAX, NULL);
if (maxsign == 0) {
maxsign = (u_int)strtonum(optarg, 1, UINT_MAX, &errstr);
if (errstr) {
usage();
ret = 1;
goto done;
Expand Down

0 comments on commit 704c937

Please sign in to comment.