]> git.puffer.fish Git - mirror/frr.git/commitdiff
[daemons] Sanity check port number arguments before use
authorPaul Jakma <paul.jakma@sun.com>
Thu, 29 May 2008 18:29:16 +0000 (18:29 +0000)
committerPaul Jakma <paul.jakma@sun.com>
Thu, 29 May 2008 18:29:16 +0000 (18:29 +0000)
2008-05-29 Martin Nagy <mnagy@redhat.com>

* */*main.c: Sanity check port numbers before using.

ChangeLog
bgpd/bgp_main.c
ospf6d/ospf6_main.c
ospfd/ospf_main.c
ripd/rip_main.c
ripngd/ripng_main.c
zebra/main.c

index ae97cf37c9b4bbbe3fec5622e9cc8cee95201ea5..2fbdd8a8756166ebd9fd7aac68b4c55832652350 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2008-05-29 Martin Nagy <mnagy@redhat.com>
+
+       * */*main.c: Sanity check port numbers before using.
+
 2008-01-30 Peter Szilagyi <sp615@hszk.bme.hu>
 
        * lib/stream.h: Remove named 'new' parameter in prototype
index e6d34afcc387880e75c5c6eb82e2ed91febfe776..2089c6b5508f48d2a278c2eb2e3c2389406a627a 100644 (file)
@@ -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;
index 8380bc89bdc3898910810d185798e311e714618f..680f4b7fa1839340fd98f71382de0834bf288e06 100644 (file)
@@ -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;
index 27a12dd04a18ffc9096ccb5448d3bb42b6216235..1a200a8f59d7807a37054bafc4445fb6eb2c3e23 100644 (file)
@@ -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;
index dfcd6c2666e944a8e65396d16c8bfc4e74151784..0b29107d30119887982d4b2d00584d792ceed492 100644 (file)
@@ -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;
index 7055391052485f7a4674a1c9b51ff51a77291cc3..a18ce9de75b20012333ccf5a93df2599a1f04bef 100644 (file)
@@ -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;
index 6019260fef66212b249b70b9dca84a7256ceecab..61750f1d07d67c0997eae1dd906a522871a28440 100644 (file)
@@ -275,7 +275,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;