diff options
author | Thomas Haller <thaller@redhat.com> | 2021-01-26 12:50:29 +0100 |
---|---|---|
committer | Jiri Pirko <jiri@nvidia.com> | 2021-01-28 10:20:50 +0100 |
commit | 3fc2ed78edb5deae0381d022bedc22ffd00d50cb (patch) | |
tree | 4d811d54293a6890ec754221859e8c099662f7e9 | |
parent | 22b452fb3110cd66da12782415362ea28c7b608c (diff) | |
download | libndp-3fc2ed78edb5deae0381d022bedc22ffd00d50cb.tar.gz |
libndp: avoid static buffer for debug string in ndp_sock_recv()
libndp should be thread safe. There is really no need to use a
static buffer in this case.
Signed-off-by: Thomas Haller <thaller@redhat.com>
Signed-off-by: Jiri Pirko <jiri@nvidia.com>
-rw-r--r-- | libndp/libndp.c | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/libndp/libndp.c b/libndp/libndp.c index a859ec7..06a3d23 100644 --- a/libndp/libndp.c +++ b/libndp/libndp.c @@ -221,11 +221,9 @@ resend: return 0; } -static const char *str_in6_addr(struct in6_addr *addr) +static const char *str_in6_addr(struct in6_addr *addr, char buf[static INET6_ADDRSTRLEN]) { - static char buf[INET6_ADDRSTRLEN]; - - return inet_ntop(AF_INET6, addr, buf, sizeof(buf)); + return inet_ntop(AF_INET6, addr, buf, INET6_ADDRSTRLEN); } @@ -1820,6 +1818,7 @@ static int ndp_sock_recv(struct ndp *ndp) enum ndp_msg_type msg_type; size_t len; int err; + char buf[INET6_ADDRSTRLEN]; msg = ndp_msg_alloc(); if (!msg) @@ -1833,7 +1832,7 @@ static int ndp_sock_recv(struct ndp *ndp) goto free_msg; } dbg(ndp, "rcvd from: %s, ifindex: %u, hoplimit: %d", - str_in6_addr(&msg->addrto), msg->ifindex, msg->hoplimit); + str_in6_addr(&msg->addrto, buf), msg->ifindex, msg->hoplimit); if (msg->hoplimit != 255) { warn(ndp, "ignoring packet with bad hop limit (%d)", msg->hoplimit); |