- check port number range when using -P or -p (#206071)

This commit is contained in:
Martin Nagy 2008-01-30 07:16:21 +00:00
parent 36287c1161
commit 897a62ee32
2 changed files with 105 additions and 1 deletions

View File

@ -0,0 +1,99 @@
diff -up quagga-0.99.9/ripngd/ripng_main.c.port_overflow quagga-0.99.9/ripngd/ripng_main.c
--- quagga-0.99.9/ripngd/ripng_main.c.port_overflow 2006-10-16 01:34:48.000000000 +0200
+++ quagga-0.99.9/ripngd/ripng_main.c 2008-01-29 17:39:58.000000000 +0100
@@ -240,7 +240,8 @@ main (int argc, char **argv)
break;
}
vty_port = atoi (optarg);
- vty_port = (vty_port ? vty_port : RIPNG_VTY_PORT);
+ if (vty_port <= 0 || vty_port > 0xffff)
+ vty_port = RIPNG_VTY_PORT;
break;
case 'r':
retain_mode = 1;
diff -up quagga-0.99.9/bgpd/bgp_main.c.port_overflow quagga-0.99.9/bgpd/bgp_main.c
--- quagga-0.99.9/bgpd/bgp_main.c.port_overflow 2006-10-16 01:34:47.000000000 +0200
+++ quagga-0.99.9/bgpd/bgp_main.c 2008-01-29 17:58:31.000000000 +0100
@@ -201,6 +201,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);
@@ -236,7 +237,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;
@@ -250,7 +255,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;
diff -up quagga-0.99.9/ripd/rip_main.c.port_overflow quagga-0.99.9/ripd/rip_main.c
--- quagga-0.99.9/ripd/rip_main.c.port_overflow 2006-10-16 01:34:48.000000000 +0200
+++ quagga-0.99.9/ripd/rip_main.c 2008-01-29 17:39:58.000000000 +0100
@@ -236,7 +236,8 @@ main (int argc, char **argv)
break;
}
vty_port = atoi (optarg);
- vty_port = (vty_port ? vty_port : RIP_VTY_PORT);
+ if (vty_port <= 0 || vty_port > 0xffff)
+ vty_port = RIP_VTY_PORT;
break;
case 'r':
retain_mode = 1;
diff -up quagga-0.99.9/ospfd/ospf_main.c.port_overflow quagga-0.99.9/ospfd/ospf_main.c
--- quagga-0.99.9/ospfd/ospf_main.c.port_overflow 2006-10-16 01:34:48.000000000 +0200
+++ quagga-0.99.9/ospfd/ospf_main.c 2008-01-29 17:39:58.000000000 +0100
@@ -245,7 +245,8 @@ main (int argc, char **argv)
break;
}
vty_port = atoi (optarg);
- vty_port = (vty_port ? vty_port : OSPF_VTY_PORT);
+ if (vty_port <= 0 || vty_port > 0xffff)
+ vty_port = OSPF_VTY_PORT;
break;
case 'u':
ospfd_privs.user = optarg;
diff -up quagga-0.99.9/ospf6d/ospf6_main.c.port_overflow quagga-0.99.9/ospf6d/ospf6_main.c
--- quagga-0.99.9/ospf6d/ospf6_main.c.port_overflow 2006-10-16 01:34:48.000000000 +0200
+++ quagga-0.99.9/ospf6d/ospf6_main.c 2008-01-29 17:39:58.000000000 +0100
@@ -227,7 +227,8 @@ main (int argc, char *argv[], char *envp
break;
}
vty_port = atoi (optarg);
- vty_port = (vty_port ? vty_port : OSPF6_VTY_PORT);
+ if (vty_port <= 0 || vty_port > 0xffff)
+ vty_port = OSPF6_VTY_PORT;
break;
case 'u':
ospf6d_privs.user = optarg;
diff -up quagga-0.99.9/zebra/main.c.port_overflow quagga-0.99.9/zebra/main.c
--- quagga-0.99.9/zebra/main.c.port_overflow 2007-05-02 17:28:33.000000000 +0200
+++ quagga-0.99.9/zebra/main.c 2008-01-29 17:39:58.000000000 +0100
@@ -276,7 +276,8 @@ main (int argc, char **argv)
break;
}
vty_port = atoi (optarg);
- vty_port = (vty_port ? vty_port : ZEBRA_VTY_PORT);
+ if (vty_port <= 0 || vty_port > 0xffff)
+ vty_port = ZEBRA_VTY_PORT;
break;
case 'r':
retain_mode = 1;

View File

@ -32,7 +32,7 @@
Summary: Routing daemon Summary: Routing daemon
Name: quagga Name: quagga
Version: 0.99.9 Version: 0.99.9
Release: 3%{?dist} Release: 4%{?dist}
Epoch: 0 Epoch: 0
License: GPL License: GPL
Group: System Environment/Daemons Group: System Environment/Daemons
@ -41,6 +41,7 @@ Source1: quagga-filter-perl-requires.sh
Patch2: quagga-0.96.5-nostart.patch Patch2: quagga-0.96.5-nostart.patch
#Patch6: quagga-0.98.5-pie.patch #Patch6: quagga-0.98.5-pie.patch
Patch7: quagga-0.99.9-initscript.patch Patch7: quagga-0.99.9-initscript.patch
Patch8: quagga-0.99.9-port_overflow.patch
URL: http://www.quagga.net URL: http://www.quagga.net
%if %with_snmp %if %with_snmp
@ -98,6 +99,7 @@ developing OSPF-API and quagga applications.
# This creates a .diff file that we apply after configuring # This creates a .diff file that we apply after configuring
#%patch6 -p1 #%patch6 -p1
%patch7 -p1 -b .initscript %patch7 -p1 -b .initscript
%patch8 -p1 -b .port_overflow
%build %build
# FC5+ automatic -fstack-protector-all switch # FC5+ automatic -fstack-protector-all switch
@ -347,6 +349,9 @@ rm -rf $RPM_BUILD_ROOT
%endif %endif
%changelog %changelog
* Tue Jan 29 2008 Martin Nagy <mnagy@redhat.com> - 0.99.9-4
- check port number range when using -P or -p (#206071)
* Wed Jan 23 2008 Martin Nagy <mnagy@redhat.com> - 0.99.9-3 * Wed Jan 23 2008 Martin Nagy <mnagy@redhat.com> - 0.99.9-3
- rebuild - rebuild