mirror of
https://gitlab.isc.org/isc-projects/dhcp
synced 2025-08-31 22:35:25 +00:00
Make sure specified UDP port is valid
This commit is contained in:
19
dhcpd.c
19
dhcpd.c
@@ -41,7 +41,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
static char objcopyright[] =
|
static char objcopyright[] =
|
||||||
"$Id: dhcpd.c,v 1.28 1996/08/29 09:49:52 mellon Exp $ Copyright 1995, 1996 The Internet Software Consortium.";
|
"$Id: dhcpd.c,v 1.29 1996/08/29 09:55:52 mellon Exp $ Copyright 1995, 1996 The Internet Software Consortium.";
|
||||||
static char copyright[] =
|
static char copyright[] =
|
||||||
"Copyright 1995, 1996 The Internet Software Consortium.";
|
"Copyright 1995, 1996 The Internet Software Consortium.";
|
||||||
static char arr [] = "All rights reserved.";
|
static char arr [] = "All rights reserved.";
|
||||||
@@ -72,6 +72,7 @@ int main (argc, argv, envp)
|
|||||||
int i, status;
|
int i, status;
|
||||||
struct servent *ent;
|
struct servent *ent;
|
||||||
int pidfilewritten = 0;
|
int pidfilewritten = 0;
|
||||||
|
char *s;
|
||||||
#ifndef DEBUG
|
#ifndef DEBUG
|
||||||
int pid;
|
int pid;
|
||||||
char pbuf [20];
|
char pbuf [20];
|
||||||
@@ -95,13 +96,19 @@ int main (argc, argv, envp)
|
|||||||
note (copyright);
|
note (copyright);
|
||||||
note (arr);
|
note (arr);
|
||||||
|
|
||||||
log_perror = 0;
|
|
||||||
|
|
||||||
for (i = 1; i < argc; i++) {
|
for (i = 1; i < argc; i++) {
|
||||||
if (!strcmp (argv [i], "-p")) {
|
if (!strcmp (argv [i], "-p")) {
|
||||||
if (++i == argc)
|
if (++i == argc)
|
||||||
usage ();
|
usage ();
|
||||||
server_port = htons (atoi (argv [i]));
|
for (s = argv [i]; *s; s++)
|
||||||
|
if (!isdigit (*s))
|
||||||
|
error ("%s: not a valid UDP port",
|
||||||
|
argv [i]);
|
||||||
|
server_port = atoi (argv [i]);
|
||||||
|
if (server_port < 1 || server_port > 65535)
|
||||||
|
error ("%s: not a valid UDP port",
|
||||||
|
argv [i]);
|
||||||
|
server_port = htons (server_port);
|
||||||
debug ("binding to user-specified port %d",
|
debug ("binding to user-specified port %d",
|
||||||
ntohs (server_port));
|
ntohs (server_port));
|
||||||
} else if (!strcmp (argv [i], "-f")) {
|
} else if (!strcmp (argv [i], "-f")) {
|
||||||
@@ -130,6 +137,8 @@ int main (argc, argv, envp)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
log_perror = 0;
|
||||||
|
|
||||||
#ifndef DEBUG
|
#ifndef DEBUG
|
||||||
if (daemon) {
|
if (daemon) {
|
||||||
/* Become a daemon... */
|
/* Become a daemon... */
|
||||||
@@ -215,7 +224,7 @@ int main (argc, argv, envp)
|
|||||||
|
|
||||||
static void usage ()
|
static void usage ()
|
||||||
{
|
{
|
||||||
error ("Usage: dhcpd [-p <port>] [-d] [-f] [if0 [...ifN]]");
|
error ("Usage: dhcpd [-p <UDP port #>] [-d] [-f] [if0 [...ifN]]");
|
||||||
}
|
}
|
||||||
|
|
||||||
void cleanup ()
|
void cleanup ()
|
||||||
|
@@ -41,7 +41,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
static char objcopyright[] =
|
static char objcopyright[] =
|
||||||
"$Id: dhcpd.c,v 1.28 1996/08/29 09:49:52 mellon Exp $ Copyright 1995, 1996 The Internet Software Consortium.";
|
"$Id: dhcpd.c,v 1.29 1996/08/29 09:55:52 mellon Exp $ Copyright 1995, 1996 The Internet Software Consortium.";
|
||||||
static char copyright[] =
|
static char copyright[] =
|
||||||
"Copyright 1995, 1996 The Internet Software Consortium.";
|
"Copyright 1995, 1996 The Internet Software Consortium.";
|
||||||
static char arr [] = "All rights reserved.";
|
static char arr [] = "All rights reserved.";
|
||||||
@@ -72,6 +72,7 @@ int main (argc, argv, envp)
|
|||||||
int i, status;
|
int i, status;
|
||||||
struct servent *ent;
|
struct servent *ent;
|
||||||
int pidfilewritten = 0;
|
int pidfilewritten = 0;
|
||||||
|
char *s;
|
||||||
#ifndef DEBUG
|
#ifndef DEBUG
|
||||||
int pid;
|
int pid;
|
||||||
char pbuf [20];
|
char pbuf [20];
|
||||||
@@ -95,13 +96,19 @@ int main (argc, argv, envp)
|
|||||||
note (copyright);
|
note (copyright);
|
||||||
note (arr);
|
note (arr);
|
||||||
|
|
||||||
log_perror = 0;
|
|
||||||
|
|
||||||
for (i = 1; i < argc; i++) {
|
for (i = 1; i < argc; i++) {
|
||||||
if (!strcmp (argv [i], "-p")) {
|
if (!strcmp (argv [i], "-p")) {
|
||||||
if (++i == argc)
|
if (++i == argc)
|
||||||
usage ();
|
usage ();
|
||||||
server_port = htons (atoi (argv [i]));
|
for (s = argv [i]; *s; s++)
|
||||||
|
if (!isdigit (*s))
|
||||||
|
error ("%s: not a valid UDP port",
|
||||||
|
argv [i]);
|
||||||
|
server_port = atoi (argv [i]);
|
||||||
|
if (server_port < 1 || server_port > 65535)
|
||||||
|
error ("%s: not a valid UDP port",
|
||||||
|
argv [i]);
|
||||||
|
server_port = htons (server_port);
|
||||||
debug ("binding to user-specified port %d",
|
debug ("binding to user-specified port %d",
|
||||||
ntohs (server_port));
|
ntohs (server_port));
|
||||||
} else if (!strcmp (argv [i], "-f")) {
|
} else if (!strcmp (argv [i], "-f")) {
|
||||||
@@ -130,6 +137,8 @@ int main (argc, argv, envp)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
log_perror = 0;
|
||||||
|
|
||||||
#ifndef DEBUG
|
#ifndef DEBUG
|
||||||
if (daemon) {
|
if (daemon) {
|
||||||
/* Become a daemon... */
|
/* Become a daemon... */
|
||||||
@@ -215,7 +224,7 @@ int main (argc, argv, envp)
|
|||||||
|
|
||||||
static void usage ()
|
static void usage ()
|
||||||
{
|
{
|
||||||
error ("Usage: dhcpd [-p <port>] [-d] [-f] [if0 [...ifN]]");
|
error ("Usage: dhcpd [-p <UDP port #>] [-d] [-f] [if0 [...ifN]]");
|
||||||
}
|
}
|
||||||
|
|
||||||
void cleanup ()
|
void cleanup ()
|
||||||
|
Reference in New Issue
Block a user