[quagga-dev 4625] patch for ospfd inet_ntoa bug

Andrew J. Schorr aschorr at telemetry-investments.com
Wed Mar 14 17:19:46 GMT 2007


In ospf_zebra.c, there are a couple of places where inet_ntoa
is used twice in the same zlog_debug message, so one of the
strings gets obliterated (there's a single static buffer).
The fix is to use inet_ntop.  Patch attached.  Any objections
to committing?

Regards,
Andy
-------------- next part --------------
Index: ospfd/ospf_zebra.c
===================================================================
RCS file: /var/cvsroot/quagga/ospfd/ospf_zebra.c,v
retrieving revision 1.42
diff -b -u -p -r1.42 ospf_zebra.c
--- ospfd/ospf_zebra.c	30 Nov 2006 16:17:02 -0000	1.42
+++ ospfd/ospf_zebra.c	14 Mar 2007 17:18:14 -0000
@@ -396,9 +396,13 @@ ospf_zebra_add (struct prefix_ipv4 *p, s
 
           if (IS_DEBUG_OSPF (zebra, ZEBRA_REDISTRIBUTE))
             {
-              zlog_debug ("Zebra: Route add %s/%d nexthop %s",
-                         inet_ntoa (p->prefix),
-                         p->prefixlen, inet_ntoa (path->nexthop));
+	      char buf[2][INET_ADDRSTRLEN];
+	      zlog_debug("Zebra: Route add %s/%d nexthop %s",
+			 inet_ntop(AF_INET, &p->prefix,
+				   buf[0], sizeof(buf[0])),
+			 p->prefixlen,
+			 inet_ntop(AF_INET, &path->nexthop,
+				   buf[1], sizeof(buf[1])));
             }
         }
 
@@ -462,9 +466,12 @@ ospf_zebra_delete (struct prefix_ipv4 *p
 
           if (IS_DEBUG_OSPF (zebra, ZEBRA_REDISTRIBUTE) && api.nexthop_num)
             {
-              zlog_debug ("Zebra: Route delete %s/%d nexthop %s",
-                         inet_ntoa (p->prefix),
-                         p->prefixlen, inet_ntoa (**api.nexthop));
+	      char buf[2][INET_ADDRSTRLEN];
+	      zlog_debug("Zebra: Route delete %s/%d nexthop %s",
+			 inet_ntop(AF_INET, &p->prefix, buf[0], sizeof(buf[0])),
+			 p->prefixlen,
+			 inet_ntop(AF_INET, *api.nexthop,
+				   buf[1], sizeof(buf[1])));
             }
           if (IS_DEBUG_OSPF (zebra, ZEBRA_REDISTRIBUTE) && api.ifindex_num)
             {


More information about the Quagga-dev mailing list