]> git.puffer.fish Git - mirror/frr.git/commitdiff
[ospfd] lsdb_delete/discard_from_db should be more robust to bad args
authorPaul Jakma <paul.jakma@sun.com>
Thu, 15 Jun 2006 12:04:57 +0000 (12:04 +0000)
committerPaul Jakma <paul.jakma@sun.com>
Thu, 15 Jun 2006 12:04:57 +0000 (12:04 +0000)
2006-05-31 Paul Jakma <paul.jakma@sun.com>

* ospf_lsdb.c: (ospf_lsdb_delete) robustify against NULL arguments,
  print warning.
* ospf_lsa.c: (ospf_discard_from_db) ditto.
  (ospf_maxage_lsa_remover) Check lsa->lsdb for validity, possible
  mitigation (but not solution) for bug #269.

ospfd/ChangeLog
ospfd/ospf_lsa.c
ospfd/ospf_lsdb.c

index 32b39aae51269ca0ee5a7c0460cfae9787ae85bd..34d7c4df79c3c272da09013cd6637837252761e5 100644 (file)
@@ -1,3 +1,11 @@
+2006-05-31 Paul Jakma <paul.jakma@sun.com>
+
+       * ospf_lsdb.c: (ospf_lsdb_delete) robustify against NULL arguments,
+         print warning.
+       * ospf_lsa.c: (ospf_discard_from_db) ditto.
+         (ospf_maxage_lsa_remover) Check lsa->lsdb for validity, possible
+         mitigation (but not solution) for bug #269.
+
 2006-05-30 Paul Jakma <paul.jakma@sun.com>
 
        * ospf_packet.c: (ospf_read) Debug message about packets
index 7c3be3d6c4940f54a123f940ce1efad013bec9b5..a0afbad39594099b36c086c25e54ec0a6b4e9b36 100644 (file)
@@ -2679,6 +2679,17 @@ ospf_discard_from_db (struct ospf *ospf,
 {
   struct ospf_lsa *old;
   
+  if (!lsdb)
+    {
+      zlog_warn ("%s: Called with NULL lsdb!", __func__);
+      if (!lsa)
+        zlog_warn ("%s: and NULL LSA!", __func__);
+      else
+        zlog_warn ("LSA[Type%d:%s]: not associated with LSDB!",
+                   lsa->data->type, inet_ntoa (lsa->data->id));
+      return;
+    }
+  
   old = ospf_lsdb_lookup (lsdb, lsa);
 
   if (!old)
@@ -3014,8 +3025,14 @@ ospf_maxage_lsa_remover (struct thread *thread)
           }
 
        /* Remove from lsdb. */
-        ospf_discard_from_db (ospf, lsa->lsdb, lsa);
-        ospf_lsdb_delete (lsa->lsdb, lsa);
+       if (lsa->lsdb)
+         {
+           ospf_discard_from_db (ospf, lsa->lsdb, lsa);
+           ospf_lsdb_delete (lsa->lsdb, lsa);
+          }
+        else
+          zlog_warn ("%s: LSA[Type%d:%s]: No associated LSDB!", __func__,
+                     lsa->data->type, inet_ntoa (lsa->data->id));
       }
 
   /*    A MaxAge LSA must be removed immediately from the router's link
index c0ec4b3df470aceabec1fa3b5971e4ed4718055b..b161b8067473ee01431ad6b74ffa0d1bee4280df 100644 (file)
@@ -127,6 +127,22 @@ ospf_lsdb_delete (struct ospf_lsdb *lsdb, struct ospf_lsa *lsa)
   struct prefix_ls lp;
   struct route_node *rn;
 
+  if (!lsdb)
+    {
+      zlog_warn ("%s: Called with NULL LSDB", __func__);
+      if (lsa)
+        zlog_warn ("LSA[Type%d:%s]: LSA %p, lsa->lsdb %p",
+                   lsa->data->type, inet_ntoa (lsa->data->id),
+                   lsa, lsa->lsdb);
+      return;
+    }
+  
+  if (!lsa)
+    {
+      zlog_warn ("%s: Called with NULL LSA", __func__);
+      return;
+    }
+  
   table = lsdb->type[lsa->data->type].db;
   lsdb_prefix_set (&lp, lsa);
   rn = route_node_lookup (table, (struct prefix *) &lp);