[LTP] [PATCH v2] gethostname02: Accept EOVERFLOW on alpha
Avinesh Kumar
avinesh.kumar@suse.com
Tue Jun 2 19:34:32 CEST 2026
Hi,
On 6/2/26 11:02 AM, panzhe wrote:
> On alpha glibc's gethostname() directly calls the kernel
> syscall and sets errno to EOVERFLOW when the buffer is
> too small, because the kernel truncates silently and the
> string is not null terminated.
>
> On the other hand, the generic posix implementation used
> on x86_64 sets ENAMETOOLONG in this case.
>
> Fix this by accepting both errnos.
>
> Closes: https://github.com/linux-test-project/ltp/issues/1319
> Signed-off-by: panzhe <panzhe@kylinos.cn>
> ---
> testcases/kernel/syscalls/gethostname/gethostname02.c | 6 ++++--
> 1 file changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/testcases/kernel/syscalls/gethostname/gethostname02.c b/testcases/kernel/syscalls/gethostname/gethostname02.c
> index c56fcb800..dd1f4e39e 100644
> --- a/testcases/kernel/syscalls/gethostname/gethostname02.c
> +++ b/testcases/kernel/syscalls/gethostname/gethostname02.c
> @@ -7,7 +7,7 @@
> /*\
> * Verify that gethostname(2) fails with
> *
> - * - ENAMETOOLONG when len is smaller than the actual size
> + * - ENAMETOOLONG or EOVERFLOW when len is smaller than the actual size
> */
>
> #include "tst_test.h"
> @@ -16,11 +16,13 @@ static void verify_gethostname(void)
> {
> char hostname[HOST_NAME_MAX + 1];
> int real_length;
> + const int exp_errnos[] = {ENAMETOOLONG, EOVERFLOW};
>
> SAFE_GETHOSTNAME(hostname, sizeof(hostname));
> real_length = strlen(hostname);
>
> - TST_EXP_FAIL(gethostname(hostname, real_length - 1), ENAMETOOLONG,
> + TST_EXP_FAIL_ARR(gethostname(hostname, real_length - 1),
> + exp_errnos, ARRAY_SIZE(exp_errnos),
Please also fix make check error here
> make check-gethostname02
CHECK testcases/kernel/syscalls/gethostname/gethostname02.c
gethostname02.c:25: CHECK: Alignment should match open parenthesis
with that
Reviewed-by: Avinesh Kumar <avinesh.kumar@suse.com>
> "len is smaller than the actual size");
> }
>
Regards,
Avinesh
More information about the ltp
mailing list