[cleanup] Use correct buffer size for inet_ntop()
Don't need big buffer 1024 to hold IPV4 (INET_ADDRSTRLEN)
or IPv6 (INET6_ADDRSTRLEN) message.
diff --git a/zebra/interface.c b/zebra/interface.c
index 9cbbf93..3e4867c 100644
--- a/zebra/interface.c
+++ b/zebra/interface.c
@@ -1513,7 +1513,6 @@
{
struct listnode *node;
struct interface *ifp;
- char buf[BUFSIZ];
for (ALL_LIST_ELEMENTS_RO (iflist, node, ifp))
{
@@ -1543,10 +1542,11 @@
{
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 b7bd567..a8107ae 100644
--- a/zebra/redistribute.c
+++ b/zebra/redistribute.c
@@ -369,13 +369,14 @@
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 @@
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 19e3c0c..e2108fc 100644
--- a/zebra/zebra_rib.c
+++ b/zebra/zebra_rib.c
@@ -1874,8 +1874,8 @@
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 @@
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 @@
{
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 @@
{
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 @@
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 @@
{
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 @@
{
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);