All of lore.kernel.org
 help / color / mirror / Atom feed
* [LTP] [PATCH v3] gethostname02: Accept EOVERFLOW on alpha
@ 2026-06-03  1:49 panzhe
  2026-06-03  9:31 ` Cyril Hrubis
  0 siblings, 1 reply; 6+ messages in thread
From: panzhe @ 2026-06-03  1:49 UTC (permalink / raw)
  To: ltp

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 | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/testcases/kernel/syscalls/gethostname/gethostname02.c b/testcases/kernel/syscalls/gethostname/gethostname02.c
index c56fcb800..23ab25010 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,12 +16,14 @@ 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,
-		"len is smaller than the actual size");
+	TST_EXP_FAIL_ARR(gethostname(hostname, real_length - 1),
+			 exp_errnos, ARRAY_SIZE(exp_errnos),
+			 "len is smaller than the actual size");
 }
 
 static struct tst_test test = {
-- 
2.25.1


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2026-06-09  9:53 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <--compose>
2026-06-04  7:26 ` [LTP] [PATCH v3] gethostname02: Accept EOVERFLOW on alpha panzhe
2026-06-04  8:43   ` Cyril Hrubis
2026-06-09  8:11   ` Andrea Cervesato via ltp
2026-06-09  9:53     ` Cyril Hrubis
2026-06-03  1:49 panzhe
2026-06-03  9:31 ` Cyril Hrubis

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.