summaryrefslogtreecommitdiffstats
path: root/bgpd/bgp_main.c
diff options
context:
space:
mode:
authorpaul <paul>2008-05-29 18:29:16 +0000
committerpaul <paul>2008-05-29 18:29:16 +0000
commita73770abf4e87b073ca51ca0cd4171d712ca9bff (patch)
tree026cb7665fff7afad5872f397c8e7814a03fb80e /bgpd/bgp_main.c
parentbccd4b06852d712dd5de868c583102bd4c2bdea1 (diff)
downloadquagga-a73770abf4e87b073ca51ca0cd4171d712ca9bff.tar.bz2
quagga-a73770abf4e87b073ca51ca0cd4171d712ca9bff.tar.xz
[daemons] Sanity check port number arguments before use
2008-05-29 Martin Nagy <mnagy@redhat.com> * */*main.c: Sanity check port numbers before using.
Diffstat (limited to 'bgpd/bgp_main.c')
-rw-r--r--bgpd/bgp_main.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/bgpd/bgp_main.c b/bgpd/bgp_main.c
index e6d34afc..2089c6b5 100644
--- a/bgpd/bgp_main.c
+++ b/bgpd/bgp_main.c
@@ -203,6 +203,7 @@ main (int argc, char **argv)
int dryrun = 0;
char *progname;
struct thread thread;
+ int tmp_port;
/* Set umask before anything for security */
umask (0027);
@@ -238,7 +239,11 @@ main (int argc, char **argv)
pid_file = optarg;
break;
case 'p':
- bm->port = atoi (optarg);
+ tmp_port = atoi (optarg);
+ if (tmp_port <= 0 || tmp_port > 0xffff)
+ bm->port = BGP_PORT_DEFAULT;
+ else
+ bm->port = tmp_port;
break;
case 'A':
vty_addr = optarg;
@@ -252,7 +257,8 @@ main (int argc, char **argv)
break;
}
vty_port = atoi (optarg);
- vty_port = (vty_port ? vty_port : BGP_VTY_PORT);
+ if (vty_port <= 0 || vty_port > 0xffff)
+ vty_port = BGP_VTY_PORT;
break;
case 'r':
retain_mode = 1;