[PATCH] nss: Add ERANGE testing to tst-nss-test4 (bug 33361)
Carlos O'Donell
carlos@redhat.com
Fri Nov 7 23:18:07 GMT 2025
On 11/7/25 6:09 PM, Carlos O'Donell wrote:
> How about this?
>
> diff --git a/nss/tst-nss-test4.c b/nss/tst-nss-test4.c
> index 0dc0ad2c29..2c6512341b 100644
> --- a/nss/tst-nss-test4.c
> +++ b/nss/tst-nss-test4.c
> @@ -95,6 +95,7 @@ do_test (void)
> int i, member_cnt;
> struct group *g = NULL;
> uintptr_t align_mask;
> + uintptr_t align_mem_mask;
>
> /* At least 3 service modules are needed to reproduce BZ#33361. */
> __nss_configure_lookup ("group", "test1 [SUCCESS=merge] test2 files");
> @@ -136,7 +137,8 @@ do_test (void)
> }
> merge_1[array_length(group_1) - 1 + member_cnt]= NULL;
>
> - align_mask = __alignof__ (struct group *) - 1;
> + align_mask = __alignof__ (struct group) - 1;
> + align_mem_mask = __alignof__ (char) - 1;
>
> setgrent ();
>
> @@ -151,7 +153,7 @@ do_test (void)
> printf ("FAIL: [%d] unaligned group %p\n", i, g);
> ++retval;
> }
> - if ((uintptr_t)(g->gr_mem) & align_mask)
> + if ((uintptr_t)(g->gr_mem[0]) & align_mem_mask)
> {
> printf ("FAIL: [%d] unaligned member list %p\n",
> i, g->gr_mem);
diff --git a/nss/tst-nss-test4.c b/nss/tst-nss-test4.c
index 0dc0ad2c29..3d94c12d08 100644
--- a/nss/tst-nss-test4.c
+++ b/nss/tst-nss-test4.c
@@ -95,6 +95,7 @@ do_test (void)
int i, member_cnt;
struct group *g = NULL;
uintptr_t align_mask;
+ uintptr_t align_mem_mask;
/* At least 3 service modules are needed to reproduce BZ#33361. */
__nss_configure_lookup ("group", "test1 [SUCCESS=merge] test2 files");
@@ -136,7 +137,8 @@ do_test (void)
}
merge_1[array_length(group_1) - 1 + member_cnt]= NULL;
- align_mask = __alignof__ (struct group *) - 1;
+ align_mask = __alignof__ (struct group) - 1;
+ align_mem_mask = __alignof__ (char *) - 1;
setgrent ();
@@ -151,7 +153,7 @@ do_test (void)
printf ("FAIL: [%d] unaligned group %p\n", i, g);
++retval;
}
- if ((uintptr_t)(g->gr_mem) & align_mask)
+ if ((uintptr_t)(g->gr_mem) & align_mem_mask)
{
printf ("FAIL: [%d] unaligned member list %p\n",
i, g->gr_mem);
Is better since we want to check the pointer alignment requirement
on the gr_mem.
--
Cheers,
Carlos.
More information about the Libc-alpha
mailing list