aboutsummaryrefslogtreecommitdiff
path: root/main.c
diff options
context:
space:
mode:
authorXavier Del Campo Romero <xavi.dcr@tutanota.com>2023-04-30 22:12:57 +0200
committerXavier Del Campo Romero <xavi.dcr@tutanota.com>2023-05-01 04:13:25 +0200
commit401c5dcf444b50d4fffa66f790aa0ee6a919a967 (patch)
treebeb9d81d41ae55d4a40f4c25de761751cbf12cbe /main.c
parentcfd0a6f7743494f63c6ac5af15bbd3e762591961 (diff)
downloadslcl-401c5dcf444b50d4fffa66f790aa0ee6a919a967.tar.gz
Fix missing error checks for strtoul(3)
Diffstat (limited to 'main.c')
-rw-r--r--main.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/main.c b/main.c
index 7fca16d..c7481d0 100644
--- a/main.c
+++ b/main.c
@@ -1107,11 +1107,12 @@ static int parse_args(const int argc, char *const argv[],
case 'p':
{
- const unsigned long portul = strtoul(optarg, NULL, 10);
+ char *endptr;
+ const unsigned long portul = strtoul(optarg, &endptr, 10);
- if (portul > UINT16_MAX)
+ if (*endptr || portul > UINT16_MAX)
{
- fprintf(stderr, "%s: invalid port %lu\n", __func__, portul);
+ fprintf(stderr, "%s: invalid port %s\n", __func__, optarg);
return -1;
}