[PATCH v3] resolv: Add test for gethostbyname_r unaligned buffer [BZ #18287]

Florian Weimer fweimer@redhat.com
Mon Jun 22 14:14:40 GMT 2026


* Sergey Kolosov:

> diff --git a/resolv/tst-resolv-gethostbyname_r-unaligned.c b/resolv/tst-resolv-gethostbyname_r-unaligned.c
> new file mode 100644
> index 0000000000..760371cf36
> --- /dev/null
> +++ b/resolv/tst-resolv-gethostbyname_r-unaligned.c
> @@ -0,0 +1,160 @@
> +/* Test for BZ #18287.
> +   This test verifies that gethostbyname_r correctly accounts for pointer

> +#include <errno.h>
> +#include <stdlib.h>
> +#include <support/check.h>
> +#include <support/check_nss.h>
> +#include <support/resolv_test.h>
> +#include <support/support.h>
> +#include <support/xmemstream.h>
> +#include <string.h>
> +#include <netdb.h>
> +#include <stdio.h>

The LLM complains that <stdbool.h> is missing, which is technically
correct.  You could also sort the #include directives alphabetically.

> +static const char host_name[] = "foo.site.example";

> +/* Test gethostbyname_r with a specified buffer size and alignment.
> +   Returns true if the buffer is sufficient, false if it's too small.  */
> +static bool
> +query_host (const char *host_name, size_t size, size_t align)

I think you can drop the host_name argument.  Using the global constant
is just fine.

Rest looks okay.  Almost there!

Thanks,
Florian



More information about the Libc-alpha mailing list