bug-hurd
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH,HURD] ttyname_r returning EINVAL


From: Samuel Thibault
Subject: [PATCH,HURD] ttyname_r returning EINVAL
Date: Fri, 5 Aug 2011 16:24:57 +0200
User-agent: Mutt/1.5.21+34 (58baf7c9f32f) (2010-12-30)

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;
     }
 



reply via email to

[Prev in Thread] Current Thread [Next in Thread]