diff options
author | Thomas Haller <thaller@redhat.com> | 2020-09-14 16:55:05 +0200 |
---|---|---|
committer | Thomas Haller <thaller@redhat.com> | 2020-09-15 15:08:03 +0200 |
commit | f6692367b14b024c963452d47edd6a3e0cb3d6bf (patch) | |
tree | 742ddfc75aa07dadc18db9587b40752065174f34 | |
parent | f295e1313a5f8b866efb5e6ee5800e2cd2afe9ea (diff) | |
download | NetworkManager-f6692367b14b024c963452d47edd6a3e0cb3d6bf.tar.gz |
libnm: mark static buffer for nm_utils_inet[46]_ntop() as thread local
I think the convenience feature about omitting the output buffer is
undesirable. Anyway, try to make it safer by using a thread local
buffer.
-rw-r--r-- | libnm-core/nm-utils.c | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/libnm-core/nm-utils.c b/libnm-core/nm-utils.c index c0913eea98..2058d110df 100644 --- a/libnm-core/nm-utils.c +++ b/libnm-core/nm-utils.c @@ -4878,7 +4878,7 @@ nm_utils_is_uuid (const char *str) return FALSE; } -static char _nm_utils_inet_ntop_buffer[NM_UTILS_INET_ADDRSTRLEN]; +static _nm_thread_local char _nm_utils_inet_ntop_buffer[NM_UTILS_INET_ADDRSTRLEN]; /** * nm_utils_inet4_ntop: (skip) @@ -4888,8 +4888,9 @@ static char _nm_utils_inet_ntop_buffer[NM_UTILS_INET_ADDRSTRLEN]; * characters. If set to %NULL, it will return a pointer to an internal, static * buffer (shared with nm_utils_inet6_ntop()). Beware, that the internal * buffer will be overwritten with ever new call of nm_utils_inet4_ntop() or - * nm_utils_inet6_ntop() that does not provide its own @dst buffer. Also, - * using the internal buffer is not thread safe. When in doubt, pass your own + * nm_utils_inet6_ntop() that does not provide its own @dst buffer. Since + * 1.28, the internal buffer is thread local and thus thread safe. Before + * it was not thread safe. When in doubt, pass your own * @dst buffer to avoid these issues. * * Wrapper for inet_ntop. @@ -4916,8 +4917,9 @@ nm_utils_inet4_ntop (in_addr_t inaddr, char *dst) * characters. If set to %NULL, it will return a pointer to an internal, static * buffer (shared with nm_utils_inet4_ntop()). Beware, that the internal * buffer will be overwritten with ever new call of nm_utils_inet4_ntop() or - * nm_utils_inet6_ntop() that does not provide its own @dst buffer. Also, - * using the internal buffer is not thread safe. When in doubt, pass your own + * nm_utils_inet6_ntop() that does not provide its own @dst buffer. Since + * 1.28, the internal buffer is thread local and thus thread safe. Before + * it was not thread safe. When in doubt, pass your own * @dst buffer to avoid these issues. * * Wrapper for inet_ntop. |