From 59ab6d31ba9248da6f1ab08d2414f20f04ad9d85 Mon Sep 17 00:00:00 2001 From: Rose <83477269+AtariDreams@users.noreply.github.com> Date: Tue, 4 Jul 2023 17:08:11 -0400 Subject: [PATCH] Do proper error handling of strtonum Checking for an error string is the proper step. Have an error string for consistency. --- ssh-add.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/ssh-add.c b/ssh-add.c index 99ba23b525e..934184bf506 100644 --- a/ssh-add.c +++ b/ssh-add.c @@ -808,6 +808,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, cert_only = 0; @@ -888,16 +889,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;