Bug 12340 - ttyname_r returns EINVAL instead of ERANGE
Summary: ttyname_r returns EINVAL instead of ERANGE
Status: RESOLVED FIXED
Alias: None
Product: glibc
Classification: Unclassified
Component: hurd (show other bugs)
Version: 2.12
: P2 minor
Target Milestone: ---
Assignee: Thomas Schwinge
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-12-22 17:29 UTC by Bruno Haible
Modified: 2014-06-30 06:20 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Last reconfirmed:
fweimer: security-


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Bruno Haible 2010-12-22 17:29:44 UTC
ttyname_r is specified in POSIX
<http://www.opengroup.org/onlinepubs/9699919799/functions/ttyname.html>.
The error condition "The value of namesize is smaller than the length of
the string to be returned" is identified with the error value ERANGE.
But sysdeps/mach/hurd/ttyname_r.c returns EINVAL in this case.
(Whereas sysdeps/posix/ttyname_r.c and sysdeps/unix/sysv/linux/ttyname_r.c
return ERANGE, as expected.)

Suggestion: Use ERANGE instead of EINVAL in sysdeps/mach/hurd/ttyname_r.c.
Comment 1 Thomas Schwinge 2012-02-18 08:38:22 UTC
Issue verified.  Patch has been posted at <http://sourceware.org/ml/libc-alpha/2011-08/msg00013.html>, now verified.  Used in Debian for some time, <http://anonscm.debian.org/viewvc/pkg-glibc/glibc-package/trunk/debian/patches/hurd-i386/submitted-ttyname_ERANGE.diff>.  Roland, OK to commit?
Comment 2 Roland McGrath 2012-02-21 19:45:36 UTC
Approved.
Comment 3 Thomas Schwinge 2012-04-04 22:38:55 UTC
Committed in d653abb723919fb11f8573cdedf65505c0eca55f.