public inbox for cygwin-cvs@sourceware.org
help / color / mirror / Atom feed
From: Corinna Vinschen <corinna@sourceware.org>
To: cygwin-cvs@sourceware.org
Subject: [newlib-cygwin/main] Cygwin: set ENOSHARE and ECASECLASH _sys_errlist[] entries to empty
Date: Wed, 28 Feb 2024 09:01:13 +0000 (GMT)	[thread overview]
Message-ID: <20240228090113.82F7C3858C35@sourceware.org> (raw)

https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=ee97ae1d5f4d42d47d828a1b4d9b05ec9cbfe042

commit ee97ae1d5f4d42d47d828a1b4d9b05ec9cbfe042
Author:     Christian Franke <christian.franke@t-online.de>
AuthorDate: Tue Feb 27 17:21:45 2024 +0100
Commit:     Corinna Vinschen <corinna@vinschen.de>
CommitDate: Wed Feb 28 09:59:07 2024 +0100

    Cygwin: set ENOSHARE and ECASECLASH _sys_errlist[] entries to empty
    
    These errno values are no longer used by Cygwin.  Change the entries
    to empty strings instead of NULL to avoid crashes in existing
    binaries directly accessing the table.  Enhance strerror_worker()
    such that empty strings also result in "Unknown error ..." messages.
    Also add a static_assert check for the _sys_errlist[] size.
    
    Signed-off-by: Christian Franke <christian.franke@t-online.de>

Diff:
---
 winsup/cygwin/errno.cc | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/winsup/cygwin/errno.cc b/winsup/cygwin/errno.cc
index 7d58e62ec142..004a4021e27b 100644
--- a/winsup/cygwin/errno.cc
+++ b/winsup/cygwin/errno.cc
@@ -167,8 +167,8 @@ const char *_sys_errlist[] =
 /* ESTALE 133 */	  "Stale NFS file handle",
 /* ENOTSUP 134 */	  "Not supported",
 /* ENOMEDIUM 135 */	  "No medium found",
-/* ENOSHARE 136 */	  "No such host or network path",
-/* ECASECLASH 137 */	  "Filename exists with different case",
+			  "", /* Was ENOSHARE 136, no longer used. */
+			  "", /* Was ECASECLASH 137, no longer used. */
 /* EILSEQ 138 */	  "Invalid or incomplete multibyte or wide character",
 /* EOVERFLOW 139 */	  "Value too large for defined data type",
 /* ECANCELED 140 */	  "Operation canceled",
@@ -177,6 +177,8 @@ const char *_sys_errlist[] =
 /* ESTRPIPE 143 */	  "Streams pipe error"
 };
 
+static_assert(143 + 1 == sizeof (_sys_errlist) / sizeof (_sys_errlist[0]));
+
 int NO_COPY_INIT _sys_nerr = sizeof (_sys_errlist) / sizeof (_sys_errlist[0]);
 };
 
@@ -228,7 +230,11 @@ strerror_worker (int errnum)
 {
   char *res;
   if (errnum >= 0 && errnum < _sys_nerr)
-    res = (char *) _sys_errlist [errnum];
+    {
+      res = (char *) _sys_errlist [errnum];
+      if (res && !*res)
+	res = NULL;
+    }
   else
     res = NULL;
   return res;

                 reply	other threads:[~2024-02-28  9:01 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240228090113.82F7C3858C35@sourceware.org \
    --to=corinna@sourceware.org \
    --cc=cygwin-cvs@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).