summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKen Brown <kbrown@cornell.edu>2021-01-20 12:01:13 -0500
committerKen Brown <kbrown@cornell.edu>2021-01-22 10:36:43 -0500
commita60a4501b77dca8f30e01327b96171ee89c278f7 (patch)
treee5feabd9bf66d0d48ce03b677c7f3bbcc9052ec6
parent4aefad2bb827afa273fcd768bd06dd618d41ae75 (diff)
downloadcygnal-a60a4501b77dca8f30e01327b96171ee89c278f7.tar.gz
cygnal-a60a4501b77dca8f30e01327b96171ee89c278f7.tar.bz2
cygnal-a60a4501b77dca8f30e01327b96171ee89c278f7.zip
Cygwin: ptsname_r: always return an error number on failure
Return EBADF on a bad file descriptor. Previously 0 was returned, in violation of the requirement in https://man7.org/linux/man-pages/man3/ptsname_r.3.html that an error number should be returned on failure. We are intentionally deviating from Linux, on which ENOTTY is returned. Addresses: https://lists.gnu.org/archive/html/bug-gnulib/2021-01/msg00245.html
-rw-r--r--winsup/cygwin/release/3.2.03
-rw-r--r--winsup/cygwin/syscalls.cc2
2 files changed, 4 insertions, 1 deletions
diff --git a/winsup/cygwin/release/3.2.0 b/winsup/cygwin/release/3.2.0
index 43725cec2..f748a9bc8 100644
--- a/winsup/cygwin/release/3.2.0
+++ b/winsup/cygwin/release/3.2.0
@@ -52,3 +52,6 @@ Bug Fixes
- Fix the errno when a path contains .. and the prefix exists but is
not a directory.
Addresses: https://lists.gnu.org/archive/html/bug-gnulib/2021-01/msg00214.html
+
+- Fix the return value when ptsname_r(3) is called with a bad file descriptor
+ Addresses: https://lists.gnu.org/archive/html/bug-gnulib/2021-01/msg00245.html
diff --git a/winsup/cygwin/syscalls.cc b/winsup/cygwin/syscalls.cc
index 7044ea903..c985142eb 100644
--- a/winsup/cygwin/syscalls.cc
+++ b/winsup/cygwin/syscalls.cc
@@ -3392,7 +3392,7 @@ ptsname_r (int fd, char *buf, size_t buflen)
cygheap_fdget cfd (fd);
if (cfd < 0)
- return 0;
+ return EBADF;
return cfd->ptsname_r (buf, buflen);
}