diff options
author | Christian Franke <christian.franke@t-online.de> | 2024-02-27 17:21:45 +0100 |
---|---|---|
committer | Corinna Vinschen <corinna@vinschen.de> | 2024-02-28 09:59:07 +0100 |
commit | ee97ae1d5f4d42d47d828a1b4d9b05ec9cbfe042 (patch) | |
tree | 6f9f39599c9f67f1dd3a8af1308026a40a8f944a /winsup/cygwin | |
parent | 6f996d7751bf25f7e4282da631eb79b93662e484 (diff) | |
download | newlib-ee97ae1d5f4d42d47d828a1b4d9b05ec9cbfe042.zip newlib-ee97ae1d5f4d42d47d828a1b4d9b05ec9cbfe042.tar.gz newlib-ee97ae1d5f4d42d47d828a1b4d9b05ec9cbfe042.tar.bz2 |
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>
Diffstat (limited to 'winsup/cygwin')
-rw-r--r-- | winsup/cygwin/errno.cc | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/winsup/cygwin/errno.cc b/winsup/cygwin/errno.cc index 7d58e62..004a402 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; |