From 8c0677fe5d91b7269364ca08fa08ed09e4c2d8c9 Mon Sep 17 00:00:00 2001 From: Bruno Haible Date: Wed, 28 Apr 2010 15:00:14 -0700 Subject: BZ #11538: Fix ttyname_r callers not to expect errno was set. --- sysdeps/unix/bsd/ptsname.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'sysdeps/unix/bsd') diff --git a/sysdeps/unix/bsd/ptsname.c b/sysdeps/unix/bsd/ptsname.c index fd446a4b66..6063201b0f 100644 --- a/sysdeps/unix/bsd/ptsname.c +++ b/sysdeps/unix/bsd/ptsname.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1998,2002 Free Software Foundation, Inc. +/* Copyright (C) 1998,2002,2010 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -44,6 +44,7 @@ int __ptsname_r (int fd, char *buf, size_t buflen) { int save_errno = errno; + int err; struct stat st; if (buf == NULL) @@ -62,8 +63,12 @@ __ptsname_r (int fd, char *buf, size_t buflen) return ERANGE; } - if (__ttyname_r (fd, buf, buflen) != 0) - return errno; + err = __ttyname_r (fd, buf, buflen); + if (err != 0) + { + __set_errno (err); + return errno; + } buf[sizeof (_PATH_DEV) - 1] = 't'; -- cgit 1.4.1