diff options
Diffstat (limited to 'nss')
-rw-r--r-- | nss/Makefile | 32 | ||||
-rw-r--r-- | nss/getaddrinfo.c | 29 | ||||
-rw-r--r-- | nss/nss_action_parse.c | 5 | ||||
-rw-r--r-- | nss/nss_test1.c | 6 |
4 files changed, 32 insertions, 40 deletions
diff --git a/nss/Makefile b/nss/Makefile index 09ce94a..1991b74 100644 --- a/nss/Makefile +++ b/nss/Makefile @@ -476,39 +476,39 @@ libof-nss_test1 = extramodules libof-nss_test2 = extramodules libof-nss_test_errno = extramodules libof-nss_test_gai_hv2_canonname = extramodules -$(objpfx)/libnss_test1.so: $(objpfx)nss_test1.os $(link-libc-deps) +$(objpfx)libnss_test1.so: $(objpfx)nss_test1.os $(link-libc-deps) $(build-module) -$(objpfx)/libnss_test2.so: $(objpfx)nss_test2.os $(link-libc-deps) +$(objpfx)libnss_test2.so: $(objpfx)nss_test2.os $(link-libc-deps) $(build-module) -$(objpfx)/libnss_test_errno.so: $(objpfx)nss_test_errno.os $(link-libc-deps) +$(objpfx)libnss_test_errno.so: $(objpfx)nss_test_errno.os $(link-libc-deps) $(build-module) -$(objpfx)/libnss_test_gai_hv2_canonname.so: \ +$(objpfx)libnss_test_gai_hv2_canonname.so: \ $(objpfx)nss_test_gai_hv2_canonname.os $(link-libc-deps) $(build-module) $(objpfx)nss_test2.os : nss_test1.c # Use the nss_files suffix for these objects as well. -$(objpfx)/libnss_test1.so$(libnss_files.so-version): $(objpfx)/libnss_test1.so +$(objpfx)libnss_test1.so$(libnss_files.so-version): $(objpfx)libnss_test1.so $(make-link) -$(objpfx)/libnss_test2.so$(libnss_files.so-version): $(objpfx)/libnss_test2.so +$(objpfx)libnss_test2.so$(libnss_files.so-version): $(objpfx)libnss_test2.so $(make-link) -$(objpfx)/libnss_test_errno.so$(libnss_files.so-version): \ - $(objpfx)/libnss_test_errno.so +$(objpfx)libnss_test_errno.so$(libnss_files.so-version): \ + $(objpfx)libnss_test_errno.so $(make-link) -$(objpfx)/libnss_test_gai_hv2_canonname.so$(libnss_files.so-version): \ - $(objpfx)/libnss_test_gai_hv2_canonname.so +$(objpfx)libnss_test_gai_hv2_canonname.so$(libnss_files.so-version): \ + $(objpfx)libnss_test_gai_hv2_canonname.so $(make-link) $(patsubst %,$(objpfx)%.out,$(tests) $(tests-container)) : \ - $(objpfx)/libnss_test1.so$(libnss_files.so-version) \ - $(objpfx)/libnss_test2.so$(libnss_files.so-version) \ - $(objpfx)/libnss_test_errno.so$(libnss_files.so-version) \ - $(objpfx)/libnss_test_gai_hv2_canonname.so$(libnss_files.so-version) + $(objpfx)libnss_test1.so$(libnss_files.so-version) \ + $(objpfx)libnss_test2.so$(libnss_files.so-version) \ + $(objpfx)libnss_test_errno.so$(libnss_files.so-version) \ + $(objpfx)libnss_test_gai_hv2_canonname.so$(libnss_files.so-version) ifeq (yes,$(have-thread-library)) $(objpfx)tst-cancel-getpwuid_r: $(shared-thread-library) endif -$(objpfx)tst-nss-files-alias-leak.out: $(objpfx)/libnss_files.so -$(objpfx)tst-nss-files-alias-truncated.out: $(objpfx)/libnss_files.so +$(objpfx)tst-nss-files-alias-leak.out: $(objpfx)libnss_files.so +$(objpfx)tst-nss-files-alias-truncated.out: $(objpfx)libnss_files.so tst-nss-gai-hv2-canonname-ENV = \ MALLOC_TRACE=$(objpfx)tst-nss-gai-hv2-canonname.mtrace \ diff --git a/nss/getaddrinfo.c b/nss/getaddrinfo.c index efe6ad3..6726ace 100644 --- a/nss/getaddrinfo.c +++ b/nss/getaddrinfo.c @@ -61,6 +61,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include <nss.h> #include <resolv/resolv-internal.h> #include <resolv/resolv_context.h> +#include <stdbit.h> #include <stdbool.h> #include <stdio.h> #include <stdio_ext.h> @@ -1462,20 +1463,6 @@ get_precedence (const struct sockaddr_in6 *in6) return match_prefix (in6, precedence, 0); } - -/* Find last bit set in a word. */ -static int -fls (uint32_t a) -{ - uint32_t mask; - int n; - for (n = 0, mask = 1 << 31; n < 32; mask >>= 1, ++n) - if ((a & mask) != 0) - break; - return n; -} - - static int rfc3484_sort (const void *p1, const void *p2, void *arg) { @@ -1658,7 +1645,7 @@ rfc3484_sort (const void *p1, const void *p2, void *arg) in_addr_t netmask1 = 0xffffffffu << (32 - a1->prefixlen); if ((in1_src_addr & netmask1) == (in1_dst_addr & netmask1)) - bit1 = fls (in1_dst_addr ^ in1_src_addr); + bit1 = stdc_leading_zeros (in1_dst_addr ^ in1_src_addr); struct sockaddr_in *in2_dst = (struct sockaddr_in *) a2->dest_addr->ai_addr; @@ -1669,7 +1656,7 @@ rfc3484_sort (const void *p1, const void *p2, void *arg) in_addr_t netmask2 = 0xffffffffu << (32 - a2->prefixlen); if ((in2_src_addr & netmask2) == (in2_dst_addr & netmask2)) - bit2 = fls (in2_dst_addr ^ in2_src_addr); + bit2 = stdc_leading_zeros (in2_dst_addr ^ in2_src_addr); } else if (a1->dest_addr->ai_family == PF_INET6) { @@ -1696,10 +1683,12 @@ rfc3484_sort (const void *p1, const void *p2, void *arg) if (i < 4) { - bit1 = fls (ntohl (in1_dst->sin6_addr.s6_addr32[i] - ^ in1_src->sin6_addr.s6_addr32[i])); - bit2 = fls (ntohl (in2_dst->sin6_addr.s6_addr32[i] - ^ in2_src->sin6_addr.s6_addr32[i])); + uint32_t set_bits1 = (in1_dst->sin6_addr.s6_addr32[i] + ^ in1_src->sin6_addr.s6_addr32[i]); + uint32_t set_bits2 = (in2_dst->sin6_addr.s6_addr32[i] + ^ in2_src->sin6_addr.s6_addr32[i]); + bit1 = stdc_leading_zeros (ntohl (set_bits1)); + bit2 = stdc_leading_zeros (ntohl (set_bits2)); } } diff --git a/nss/nss_action_parse.c b/nss/nss_action_parse.c index 2b67a8a..ee3aadf 100644 --- a/nss/nss_action_parse.c +++ b/nss/nss_action_parse.c @@ -168,13 +168,16 @@ nss_action_list action_list_init (&list); if (nss_action_parse (line, &list)) { + nss_action_list retval; size_t size; struct nss_action null_service = { .module = NULL, }; action_list_add (&list, null_service); size = action_list_size (&list); - return __nss_action_allocate (action_list_begin (&list), size); + retval = __nss_action_allocate (action_list_begin (&list), size); + action_list_free (&list); + return retval; } else if (action_list_has_failed (&list)) { diff --git a/nss/nss_test1.c b/nss/nss_test1.c index f023f46..b715bc3 100644 --- a/nss/nss_test1.c +++ b/nss/nss_test1.c @@ -28,9 +28,9 @@ to test known bad data. */ #define alloc_buffer_maybe_copy_string(b,s) s ? alloc_buffer_copy_string (b, s) : NULL; -/* This file is the master template. Other instances of this test - module should define NAME(x) to have their name instead of "test1", - then include this file. +/* This file is both a standalone test and a parametrized template. + Other instances of this test module should define NAME(x) to have + their name instead of "test1", then include this file. */ #define NAME_(x,n) _nss_##n##_##x #ifndef NAME |