]> git.puffer.fish Git - mirror/frr.git/commitdiff
[ospfd] Fix missing check for ospf_lookup NULL return, CID #70
authorPaul Jakma <paul.jakma@sun.com>
Thu, 11 May 2006 13:31:11 +0000 (13:31 +0000)
committerPaul Jakma <paul.jakma@sun.com>
Thu, 11 May 2006 13:31:11 +0000 (13:31 +0000)
2006-05-11 Paul Jakma <paul.jakma@sun.com>

* ospf_vty.c: (general) Audit ospf_lookup calls in commands,
  ensure check for NULL result, make vty messages consistent.
  (show_ip_ospf_interface) Missing NULL check on ospf_lookup
  result, fixes Coverity CID #70.

ospfd/ChangeLog
ospfd/ospf_vty.c

index 99599f54f69191e6aa1fa112d1c043d9f7d843a6..46639516d697bb462f4ea950b33c994aeac60fe7 100644 (file)
@@ -1,3 +1,10 @@
+2006-05-11 Paul Jakma <paul.jakma@sun.com>
+
+       * ospf_vty.c: (general) Audit ospf_lookup calls in commands,
+         ensure check for NULL result, make vty messages consistent. 
+         (show_ip_ospf_interface) Missing NULL check on ospf_lookup
+         result, fixes Coverity CID #70.
+
 2006-04-24 Paul Jakma <paul.jakma@sun.com>
 
        * (general) More Virtual-link fixes, again with much help in
index 74361bcb6f091c6be9a5e01590c7bb0e3bf79fb8..c5a69dcecffed0d3c696840e2ae57322e7fb50b3 100644 (file)
@@ -2860,6 +2860,11 @@ DEFUN (show_ip_ospf_interface,
   struct listnode *node;
 
   ospf = ospf_lookup ();
+  if (ospf == NULL)
+    {
+      vty_out (vty, "OSPF Routing Process not enabled%s", VTY_NEWLINE);
+      return CMD_SUCCESS;
+    }
 
   /* Show All Interfaces. */
   if (argc == 0)
@@ -3976,7 +3981,10 @@ DEFUN (show_ip_ospf_database,
 
   ospf = ospf_lookup ();
   if (ospf == NULL)
-    return CMD_SUCCESS;
+    {
+      vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
+      return CMD_SUCCESS;
+    }
 
   vty_out (vty, "%s       OSPF Router with ID (%s)%s%s", VTY_NEWLINE,
            inet_ntoa (ospf->router_id), VTY_NEWLINE, VTY_NEWLINE);
@@ -4114,7 +4122,10 @@ DEFUN (show_ip_ospf_database_type_adv_router,
 
   ospf = ospf_lookup ();
   if (ospf == NULL)
-    return CMD_SUCCESS;
+    {
+      vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
+      return CMD_SUCCESS;
+    }
 
   vty_out (vty, "%s       OSPF Router with ID (%s)%s%s", VTY_NEWLINE,
            inet_ntoa (ospf->router_id), VTY_NEWLINE, VTY_NEWLINE);
@@ -4736,10 +4747,7 @@ ospf_vty_dead_interval_set (struct vty *vty, const char *interval_str,
   struct ospf_if_params *params;
   struct ospf_interface *oi;
   struct route_node *rn;
-  struct ospf *ospf;
       
-  ospf = ospf_lookup ();
-
   params = IF_DEF_PARAMS (ifp);
   
   if (nbr_str)
@@ -4787,7 +4795,8 @@ ospf_vty_dead_interval_set (struct vty *vty, const char *interval_str,
   /* Update timer values in neighbor structure. */
   if (nbr_str)
     {
-      if (ospf)
+      struct ospf *ospf;
+      if ((ospf = ospf_lookup()))
        {
          oi = ospf_if_lookup_by_local_addr (ospf, ifp, addr);
          if (oi)
@@ -4877,9 +4886,6 @@ DEFUN (no_ip_ospf_dead_interval,
   struct ospf_if_params *params;
   struct ospf_interface *oi;
   struct route_node *rn;
-  struct ospf *ospf;
-  
-  ospf = ospf_lookup ();
 
   ifp = vty->index;
   params = IF_DEF_PARAMS (ifp);
@@ -4914,7 +4920,9 @@ DEFUN (no_ip_ospf_dead_interval,
   /* Update timer values in neighbor structure. */
   if (argc == 1)
     {
-      if (ospf)
+      struct ospf *ospf;
+      
+      if ((ospf = ospf_lookup()))
        {
          oi = ospf_if_lookup_by_local_addr (ospf, ifp, addr);
          if (oi)
@@ -7138,10 +7146,9 @@ DEFUN (show_ip_ospf_border_routers,
 {
   struct ospf *ospf;
 
-  ospf = ospf_lookup ();
-  if (ospf == NULL)
+  if ((ospf = ospf_lookup ()) == NULL)
     {
-      vty_out (vty, "OSPF is not enabled%s", VTY_NEWLINE);
+      vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
       return CMD_SUCCESS;
     }
 
@@ -7170,10 +7177,9 @@ DEFUN (show_ip_ospf_route,
 {
   struct ospf *ospf;
 
-  ospf = ospf_lookup ();
-  if (ospf == NULL)
+  if ((ospf = ospf_lookup ()) == NULL)
     {
-      vty_out (vty, "OSPF is not enabled%s", VTY_NEWLINE);
+      vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
       return CMD_SUCCESS;
     }