On Sat, May 23, 2015 at 11:08:41AM +0300, Timo Teräs wrote:
> This makes code more robust, consice and readable.
Applied (4 of 4), Thanks!
I changed one single byte:
> @@ -82,7 +82,7 @@ static void __attribute__((format (printf, 4, 5)))
> _rnode_zlog(const char *_func, struct route_node *rn, int priority,
> const char *msgfmt, ...)
> {
> - char buf[INET6_ADDRSTRLEN + 4], *bptr;
> + char buf[PREFIX_STRLEN + 4];
> + char buf[PREFIX_STRLEN + 8];
-- 4 to 8 here ---------------^
because:
[...]
> - snprintf(bptr, buf + sizeof(buf) - bptr, "/%d%s", rn->p.prefixlen,
> - info->safi == SAFI_MULTICAST ? " (MRIB)" : "");
> + prefix2str(&rn->p, buf, sizeof(buf));
> + if (info->safi == SAFI_MULTICAST)
> + strcat(buf, " (MRIB)");
The extra bytes are for the (MRIB) marker. The code was previously
assuming MRIB is IPv4 only, i.e. INET6_ADDRSTRLEN+4 for IPv6 is just the
normal length of an IPv6 prefix+len - without " (MRIB)".
However, since strcat is less safe than snprintf, and since IPv6 MRIB
support isn't really blocked by anything, the +8 now provides enough
space for IPv6 prefix + len + (MRIB).
-David
_______________________________________________
Quagga-dev mailing list
[email protected]
https://lists.quagga.net/mailman/listinfo/quagga-dev