summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStephen Hemminger <stephen.hemminger@vyatta.com>2009-04-28 14:28:00 -0700
committerPaul Jakma <paul@quagga.net>2009-06-18 20:18:27 +0100
commit81cce0185e23b6ecd2ab98ab34182901226bcf9e (patch)
tree24a8fa282d80b9dab623bb26fbbec731c0c8b34a
parent82f5ee1ead0aa83f83f918abfc3f5071741a56e5 (diff)
[cleanup] Use correct buffer size for inet_ntop()
Don't need big buffer 1024 to hold IPV4 (INET_ADDRSTRLEN) or IPv6 (INET6_ADDRSTRLEN) message.
-rw-r--r--zebra/interface.c4
-rw-r--r--zebra/redistribute.c10
-rw-r--r--zebra/zebra_rib.c34
3 files changed, 25 insertions, 23 deletions
diff --git a/zebra/interface.c b/zebra/interface.c
index 9cbbf937..3e4867c4 100644
--- a/zebra/interface.c
+++ b/zebra/interface.c
@@ -1513,7 +1513,6 @@ if_config_write (struct vty *vty)
{
struct listnode *node;
struct interface *ifp;
- char buf[BUFSIZ];
for (ALL_LIST_ELEMENTS_RO (iflist, node, ifp))
{
@@ -1543,10 +1542,11 @@ if_config_write (struct vty *vty)
{
if (CHECK_FLAG (ifc->conf, ZEBRA_IFC_CONFIGURED))
{
+ char buf[INET6_ADDRSTRLEN];
p = ifc->address;
vty_out (vty, " ip%s address %s/%d",
p->family == AF_INET ? "" : "v6",
- inet_ntop (p->family, &p->u.prefix, buf, BUFSIZ),
+ inet_ntop (p->family, &p->u.prefix, buf, sizeof(buf)),
p->prefixlen);
if (ifc->label)
diff --git a/zebra/redistribute.c b/zebra/redistribute.c
index b7bd5674..a8107aeb 100644
--- a/zebra/redistribute.c
+++ b/zebra/redistribute.c
@@ -369,13 +369,14 @@ zebra_interface_address_add_update (struct interface *ifp,
struct listnode *node, *nnode;
struct zserv *client;
struct prefix *p;
- char buf[BUFSIZ];
if (IS_ZEBRA_DEBUG_EVENT)
{
+ char buf[INET6_ADDRSTRLEN];
+
p = ifc->address;
zlog_debug ("MESSAGE: ZEBRA_INTERFACE_ADDRESS_ADD %s/%d on %s",
- inet_ntop (p->family, &p->u.prefix, buf, BUFSIZ),
+ inet_ntop (p->family, &p->u.prefix, buf, INET6_ADDRSTRLEN),
p->prefixlen, ifc->ifp->name);
}
@@ -394,13 +395,14 @@ zebra_interface_address_delete_update (struct interface *ifp,
struct listnode *node, *nnode;
struct zserv *client;
struct prefix *p;
- char buf[BUFSIZ];
if (IS_ZEBRA_DEBUG_EVENT)
{
+ char buf[INET6_ADDRSTRLEN];
+
p = ifc->address;
zlog_debug ("MESSAGE: ZEBRA_INTERFACE_ADDRESS_DELETE %s/%d on %s",
- inet_ntop (p->family, &p->u.prefix, buf, BUFSIZ),
+ inet_ntop (p->family, &p->u.prefix, buf, INET6_ADDRSTRLEN),
p->prefixlen, ifc->ifp->name);
}
diff --git a/zebra/zebra_rib.c b/zebra/zebra_rib.c
index 19e3c0cd..e2108fcb 100644
--- a/zebra/zebra_rib.c
+++ b/zebra/zebra_rib.c
@@ -1874,8 +1874,8 @@ rib_delete_ipv4 (int type, int flags, struct prefix_ipv4 *p,
struct rib *fib = NULL;
struct rib *same = NULL;
struct nexthop *nexthop;
- char buf1[BUFSIZ];
- char buf2[BUFSIZ];
+ char buf1[INET_ADDRSTRLEN];
+ char buf2[INET_ADDRSTRLEN];
/* Lookup table. */
table = vrf_table (AFI_IP, SAFI_UNICAST, 0);
@@ -1887,7 +1887,7 @@ rib_delete_ipv4 (int type, int flags, struct prefix_ipv4 *p,
if (IS_ZEBRA_DEBUG_KERNEL && gate)
zlog_debug ("rib_delete_ipv4(): route delete %s/%d via %s ifindex %d",
- inet_ntop (AF_INET, &p->prefix, buf1, BUFSIZ),
+ inet_ntop (AF_INET, &p->prefix, buf1, INET_ADDRSTRLEN),
p->prefixlen,
inet_ntoa (*gate),
ifindex);
@@ -1900,13 +1900,13 @@ rib_delete_ipv4 (int type, int flags, struct prefix_ipv4 *p,
{
if (gate)
zlog_debug ("route %s/%d via %s ifindex %d doesn't exist in rib",
- inet_ntop (AF_INET, &p->prefix, buf1, BUFSIZ),
+ inet_ntop (AF_INET, &p->prefix, buf1, INET_ADDRSTRLEN),
p->prefixlen,
- inet_ntop (AF_INET, gate, buf2, BUFSIZ),
+ inet_ntop (AF_INET, gate, buf2, INET_ADDRSTRLEN),
ifindex);
else
zlog_debug ("route %s/%d ifindex %d doesn't exist in rib",
- inet_ntop (AF_INET, &p->prefix, buf1, BUFSIZ),
+ inet_ntop (AF_INET, &p->prefix, buf1, INET_ADDRSTRLEN),
p->prefixlen,
ifindex);
}
@@ -1966,14 +1966,14 @@ rib_delete_ipv4 (int type, int flags, struct prefix_ipv4 *p,
{
if (gate)
zlog_debug ("route %s/%d via %s ifindex %d type %d doesn't exist in rib",
- inet_ntop (AF_INET, &p->prefix, buf1, BUFSIZ),
+ inet_ntop (AF_INET, &p->prefix, buf1, INET_ADDRSTRLEN),
p->prefixlen,
- inet_ntop (AF_INET, gate, buf2, BUFSIZ),
+ inet_ntop (AF_INET, gate, buf2, INET_ADDRSTRLEN),
ifindex,
type);
else
zlog_debug ("route %s/%d ifindex %d type %d doesn't exist in rib",
- inet_ntop (AF_INET, &p->prefix, buf1, BUFSIZ),
+ inet_ntop (AF_INET, &p->prefix, buf1, INET_ADDRSTRLEN),
p->prefixlen,
ifindex,
type);
@@ -2429,8 +2429,8 @@ rib_delete_ipv6 (int type, int flags, struct prefix_ipv6 *p,
struct rib *fib = NULL;
struct rib *same = NULL;
struct nexthop *nexthop;
- char buf1[BUFSIZ];
- char buf2[BUFSIZ];
+ char buf1[INET6_ADDRSTRLEN];
+ char buf2[INET6_ADDRSTRLEN];
/* Apply mask. */
apply_mask_ipv6 (p);
@@ -2448,13 +2448,13 @@ rib_delete_ipv6 (int type, int flags, struct prefix_ipv6 *p,
{
if (gate)
zlog_debug ("route %s/%d via %s ifindex %d doesn't exist in rib",
- inet_ntop (AF_INET6, &p->prefix, buf1, BUFSIZ),
+ inet_ntop (AF_INET6, &p->prefix, buf1, INET6_ADDRSTRLEN),
p->prefixlen,
- inet_ntop (AF_INET6, gate, buf2, BUFSIZ),
+ inet_ntop (AF_INET6, gate, buf2, INET6_ADDRSTRLEN),
ifindex);
else
zlog_debug ("route %s/%d ifindex %d doesn't exist in rib",
- inet_ntop (AF_INET6, &p->prefix, buf1, BUFSIZ),
+ inet_ntop (AF_INET6, &p->prefix, buf1, INET6_ADDRSTRLEN),
p->prefixlen,
ifindex);
}
@@ -2514,14 +2514,14 @@ rib_delete_ipv6 (int type, int flags, struct prefix_ipv6 *p,
{
if (gate)
zlog_debug ("route %s/%d via %s ifindex %d type %d doesn't exist in rib",
- inet_ntop (AF_INET6, &p->prefix, buf1, BUFSIZ),
+ inet_ntop (AF_INET6, &p->prefix, buf1, INET6_ADDRSTRLEN),
p->prefixlen,
- inet_ntop (AF_INET6, gate, buf2, BUFSIZ),
+ inet_ntop (AF_INET6, gate, buf2, INET6_ADDRSTRLEN),
ifindex,
type);
else
zlog_debug ("route %s/%d ifindex %d type %d doesn't exist in rib",
- inet_ntop (AF_INET6, &p->prefix, buf1, BUFSIZ),
+ inet_ntop (AF_INET6, &p->prefix, buf1, INET6_ADDRSTRLEN),
p->prefixlen,
ifindex,
type);