diff --git a/src/iodined.c b/src/iodined.c index 0d4694d..3b4652c 100644 --- a/src/iodined.c +++ b/src/iodined.c @@ -495,10 +495,6 @@ main(int argc, char **argv) break; case 'p': port = atoi(optarg); - if (port) { - printf("ALERT! Other dns servers expect you to run on port 53.\n"); - printf("You must manually forward port 53 to port %d for things to work.\n", port); - } break; case 'P': strncpy(password, optarg, sizeof(password)); @@ -547,6 +543,16 @@ main(int argc, char **argv) warnx("Bad MTU given.\n"); usage(); } + + if(port < 1 || port > 65535) { + warnx("Bad port number given.\n"); + usage(); + } + + if (port != 53) { + printf("ALERT! Other dns servers expect you to run on port 53.\n"); + printf("You must manually forward port 53 to port %d for things to work.\n", port); + } if (listen_ip == INADDR_NONE) { warnx("Bad IP address to listen on.\n");