From d27cc759ccd977816f1f32a89dd6d27cc6772b22 Mon Sep 17 00:00:00 2001 From: Sami Kerola Date: Sun, 21 Aug 2016 18:32:16 +0100 Subject: [PATCH] cleanup: move max port number to be a define in net.h --- mtr.c | 4 ++-- net.h | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/mtr.c b/mtr.c index 83b57bc..fd254ba 100644 --- a/mtr.c +++ b/mtr.c @@ -597,13 +597,13 @@ void parse_arg (int argc, char **argv) break; case 'P': remoteport = strtoint_or_err(optarg, "invalid argument"); - if (remoteport > 65535 || remoteport < 1) { + if (remoteport < 1 || MaxPort < remoteport) { error(EXIT_FAILURE, 0, "Illegal port number: %d", remoteport); } break; case 'L': localport = strtoint_or_err(optarg, "invalid argument"); - if (localport > 65535 || localport < MinPort) { + if (localport < MinPort || MaxPort < localport) { error(EXIT_FAILURE, 0, "Illegal port number: %d", localport); } break; diff --git a/net.h b/net.h index 0350a4a..e8daa9d 100644 --- a/net.h +++ b/net.h @@ -86,6 +86,7 @@ void net_process_fds(fd_set *writefd); #define MinSequence 33000 #define MaxSequence 65536 #define MinPort 1024 +#define MaxPort 65535 #define MAXPACKET 4470 /* largest test packet size */ #define MINPACKET 28 /* 20 bytes IP header and 8 bytes ICMP or UDP */ -- 2.47.3