[PATCH] alpha: Fix gethostname errno for a too-small buffer

Magnus Lindholm <[email protected]>
Newsgroups gmane.comp.lib.glibc.alpha
Message-ID <[email protected]>
alpha is the only target that implements gethostname with the syscall
rather than through uname, and it reports EOVERFLOW when the name does
not fit.  Every other target, gethostname(2) and misc/tst-gethostname
expect ENAMETOOLONG:

  tst-gethostname.c:96: numeric comparison failure
     left: 112 (0x70, EOVERFLOW); from: errno
    right: 63 (0x3f); from: ENAMETOOLONG

The kernel already truncates the name and fills the buffer, so only the
errno value changes. misc/tst-gethostname passes on alpha with this.

Signed-off-by: Magnus Lindholm <[email protected]>
---
 sysdeps/unix/sysv/linux/alpha/gethostname.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/sysdeps/unix/sysv/linux/alpha/gethostname.c b/sysdeps/unix/sysv/linux/alpha/gethostname.c
index d2bd213c24..b7ac91bb30 100644
--- a/sysdeps/unix/sysv/linux/alpha/gethostname.c
+++ b/sysdeps/unix/sysv/linux/alpha/gethostname.c
@@ -34,7 +34,7 @@ __gethostname (char *name, size_t len)
 	 an error.  */
       && memchr (name, '\0', len) == NULL)
     {
-      __set_errno (EOVERFLOW);
+      __set_errno (ENAMETOOLONG);
       result = -1;
     }
 
-- 
2.55.0
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.