iproute: fix printing resolved localhost
format_host_rta_r might return a cached hostname via its return value and not use the input buffer. Before: $ ip -resolve -6 route dev lo proto kernel metric 256 pref medium After: $ ip/ip -resolve -6 route localhost dev lo proto kernel metric 256 pref medium Bug-Debian: https://bugs.debian.org/983591 Reported-by: Axel Scheepers <axel.scheepers76@gmail.com> Signed-off-by: Luca Boccassi <bluca@debian.org> Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
This commit is contained in:
parent
9d00602f82
commit
6739068fb0
|
|
@ -796,9 +796,10 @@ int print_route(struct nlmsghdr *n, void *arg)
|
||||||
"%s/%u", rt_addr_n2a_rta(family, tb[RTA_DST]),
|
"%s/%u", rt_addr_n2a_rta(family, tb[RTA_DST]),
|
||||||
r->rtm_dst_len);
|
r->rtm_dst_len);
|
||||||
} else {
|
} else {
|
||||||
format_host_rta_r(family, tb[RTA_DST],
|
const char *hostname = format_host_rta_r(family, tb[RTA_DST],
|
||||||
b1, sizeof(b1));
|
b1, sizeof(b1));
|
||||||
|
if (hostname)
|
||||||
|
strncpy(b1, hostname, sizeof(b1) - 1);
|
||||||
}
|
}
|
||||||
} else if (r->rtm_dst_len) {
|
} else if (r->rtm_dst_len) {
|
||||||
snprintf(b1, sizeof(b1), "0/%d ", r->rtm_dst_len);
|
snprintf(b1, sizeof(b1), "0/%d ", r->rtm_dst_len);
|
||||||
|
|
@ -818,8 +819,10 @@ int print_route(struct nlmsghdr *n, void *arg)
|
||||||
rt_addr_n2a_rta(family, tb[RTA_SRC]),
|
rt_addr_n2a_rta(family, tb[RTA_SRC]),
|
||||||
r->rtm_src_len);
|
r->rtm_src_len);
|
||||||
} else {
|
} else {
|
||||||
format_host_rta_r(family, tb[RTA_SRC],
|
const char *hostname = format_host_rta_r(family, tb[RTA_SRC],
|
||||||
b1, sizeof(b1));
|
b1, sizeof(b1));
|
||||||
|
if (hostname)
|
||||||
|
strncpy(b1, hostname, sizeof(b1) - 1);
|
||||||
}
|
}
|
||||||
print_color_string(PRINT_ANY, color,
|
print_color_string(PRINT_ANY, color,
|
||||||
"from", "from %s ", b1);
|
"from", "from %s ", b1);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue