[daemons] Sanity check port number arguments before use

2008-05-29 Martin Nagy <mnagy@redhat.com>

	* */*main.c: Sanity check port numbers before using.
diff --git a/ripd/rip_main.c b/ripd/rip_main.c
index dfcd6c2..0b29107 100644
--- a/ripd/rip_main.c
+++ b/ripd/rip_main.c
@@ -236,7 +236,8 @@
               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;