[PATCH,HURD] ttyname_r returning EINVAL
Samuel Thibault
samuel.thibault@gnu.org
Fri Aug 5 15:02:00 GMT 2011
From: Simon Josefsson <simon@josefsson.org>
> As explained as 4) in this e-mail:
>
> https://lists.gnu.org/archive/html/bug-gnulib/2011-08/msg00027.html
>
> it seems like the ttyname_r function returns EINVAL when the provided
> buffer is too small.
>
> This doesn't seem consistent with the specifcation at:
>
> http://pubs.opengroup.org/onlinepubs/9699919799/functions/ttyname.html
>
> Instead, it seems this should be ERANGE?
>
> [ERANGE]
> The value of namesize is smaller than the length of the string to be
> returned including the terminating null character.
I agree, here is a patch.
2011-08-05 Simon Josefsson <simon@josefsson.org>
* sysdeps/mach/hurd/ttyname_r.c (__ttyname_r): Return ERANGE instead of
EINVAL when BUFLEN is too smal.
diff --git a/sysdeps/mach/hurd/ttyname_r.c b/sysdeps/mach/hurd/ttyname_r.c
index 5f6c9c3..5718fca 100644
--- a/sysdeps/mach/hurd/ttyname_r.c
+++ b/sysdeps/mach/hurd/ttyname_r.c
@@ -43,7 +43,7 @@ __ttyname_r (int fd, char *buf, size_t buflen)
len = strlen (nodename) + 1;
if (len > buflen)
{
- errno = EINVAL;
+ errno = ERANGE;
return errno;
}
More information about the Libc-alpha
mailing list