* [LTP] [PATCH] gethostname: Fix ENAMETOOLONG on 64 character hostnames
@ 2025-01-22 19:16 Ian Whitfield
2025-01-23 11:39 ` Cyril Hrubis
0 siblings, 1 reply; 2+ messages in thread
From: Ian Whitfield @ 2025-01-22 19:16 UTC (permalink / raw)
To: ltp
HOST_NAME_MAX does not include the null terminator, so the hostname
buffer in gethostname02.c needs an extra character of space to support
maximum length hostnames.
Signed-off-by: Ian Whitfield <ian.whitfield@canonical.com>
---
testcases/kernel/syscalls/gethostname/gethostname02.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/testcases/kernel/syscalls/gethostname/gethostname02.c b/testcases/kernel/syscalls/gethostname/gethostname02.c
index 250e5f2fd..f792371ed 100644
--- a/testcases/kernel/syscalls/gethostname/gethostname02.c
+++ b/testcases/kernel/syscalls/gethostname/gethostname02.c
@@ -16,7 +16,7 @@
static void verify_gethostname(void)
{
- char hostname[HOST_NAME_MAX];
+ char hostname[HOST_NAME_MAX + 1];
int real_length;
SAFE_GETHOSTNAME(hostname, sizeof(hostname));
--
2.43.0
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [LTP] [PATCH] gethostname: Fix ENAMETOOLONG on 64 character hostnames
2025-01-22 19:16 [LTP] [PATCH] gethostname: Fix ENAMETOOLONG on 64 character hostnames Ian Whitfield
@ 2025-01-23 11:39 ` Cyril Hrubis
0 siblings, 0 replies; 2+ messages in thread
From: Cyril Hrubis @ 2025-01-23 11:39 UTC (permalink / raw)
To: Ian Whitfield; +Cc: ltp
Hi!
Good catch, applied, thanks.
--
Cyril Hrubis
chrubis@suse.cz
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2025-01-23 11:39 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-01-22 19:16 [LTP] [PATCH] gethostname: Fix ENAMETOOLONG on 64 character hostnames Ian Whitfield
2025-01-23 11:39 ` Cyril Hrubis
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox