[LTP] gethostname02: Accept EOVERFLOW on alpha
linuxtestproject.agent@gmail.com
linuxtestproject.agent@gmail.com
Tue Jun 2 13:26:56 CEST 2026
Hi panzhe,
On Tue, 2026-06-02 at 17:02 +0800, panzhe wrote:
> gethostname02: Accept EOVERFLOW on alpha
>
> 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>
Commit message: OK. The alpha-specific behaviour is confirmed by glibc's
sysdeps/unix/sysv/linux/alpha/gethostname.c:
result = INLINE_SYSCALL(gethostname, 2, name, len);
if (result == 0 && memchr(name, '\0', len) == NULL) {
__set_errno(EOVERFLOW);
result = -1;
}
When the kernel truncates the hostname to exactly `len` bytes (no null
terminator), glibc detects the missing '\0' and raises EOVERFLOW. The
commit message accurately describes this.
> - TST_EXP_FAIL(gethostname(hostname, real_length - 1), ENAMETOOLONG,
> + const int exp_errnos[] = {ENAMETOOLONG, EOVERFLOW};
> + TST_EXP_FAIL_ARR(gethostname(hostname, real_length - 1),
> + exp_errnos, ARRAY_SIZE(exp_errnos),
> + "len is smaller than the actual size");
TST_EXP_FAIL_ARR usage is correct. The array is passed as const int *,
matching the tst_errno_in_set() signature. ARRAY_SIZE is preferred over a
hardcoded count. EOVERFLOW is available via <errno.h>, which tst_test.h
already includes.
Note: ltp-linter was not available in the review environment and could not
be run.
Verdict: Reviewed
Reviewed-by: LTP AI Reviewer <ltp-ai-reviewer@lists.linux.it>
LTP AI Reviewer
More information about the ltp
mailing list