From: Bruno Haible <bruno@clisp.org>
To: bug-gnulib@gnu.org, Igor Todorovski <itodorov@ca.ibm.com>
Cc: Mike Fulton <fultonm@ca.ibm.com>
Subject: Re: Z/OS Enhancement to gnu lib
Date: Mon, 30 Jan 2023 23:12:04 +0100 [thread overview]
Message-ID: <2175144.6JPRsyc7qm@nimes> (raw)
In-Reply-To: <BN7PR15MB24664607D820FE12647F72B5EDD39@BN7PR15MB2466.namprd15.prod.outlook.com>
Igor Todorovski wrote:
> This was the symptom we experienced with findutils (guarding the close in gnulib fixed it):
> find . -name "test"
> The output is:
> find: '.': EDC5113I Bad file descriptor.
>
> https://github.com/ZOSOpenTools/findutilsport/issues/4
>
> We’ll do some more testing to see if there’s a better solution.
I'm sending you a testdir, generated through
./gnulib-tool --create-testdir --dir=/tmp/testdir --single-configure \
areadlinkat areadlinkat-with-size faccessat fchmodat fchownat
fdopendir getcwd fstatat linkat mkdirat mkfifoat openat
readlinkat renameatu savedir symlinkat unlinkat utimensat
As part of your testing, please run it through
./configure && make && make check
(Sent via private mail, as it's too large for this mailing list.)
> __e2a_l is documented here: https://www.ibm.com/docs/en/zos/2.2.0?topic=functions-e2a-l-convert-characters-from-ebcdic-ascii
Well, according to this documentation your patch was buggy: it did not
check the return value. Additionally, it ran a conversion on a buffer
full of uninitialized data (which is 1. slow and 2. triggers warnings
in tools like valgrind). And when w_ioctl failed, your code was
accessing and returning unitialized data in dir[]. Ouch ouch ouch.
Fixing it like this:
2023-01-30 Bruno Haible <bruno@clisp.org>
at-internal: Fix support for z/OS.
* lib/openat-proc.c (openat_proc_name) [z/OS]: Proper error handling.
Convert only the relevant part of the dir[] buffer.
diff --git a/lib/openat-proc.c b/lib/openat-proc.c
index 6419a8cf5f..88f70be4f5 100644
--- a/lib/openat-proc.c
+++ b/lib/openat-proc.c
@@ -123,8 +123,16 @@ openat_proc_name (char buf[OPENAT_BUFFER_SIZE], int fd, char const *file)
# endif
# ifdef __MVS__
char dir[_XOPEN_PATH_MAX];
- if (w_ioctl (fd, _IOCC_GPN, sizeof dir, dir) == 0)
- __e2a_l (dir, sizeof dir);
+ /* Documentation:
+ https://www.ibm.com/docs/en/zos/2.2.0?topic=functions-w-ioctl-w-pioctl-control-devices */
+ if (w_ioctl (fd, _IOCC_GPN, sizeof dir, dir) < 0)
+ return NULL;
+ /* Documentation:
+ https://www.ibm.com/docs/en/zos/2.2.0?topic=functions-e2a-l-convert-characters-from-ebcdic-ascii */
+ dirlen = __e2a_l (dir, strlen (dir));
+ if (dirlen < 0 || dirlen >= sizeof dir)
+ return NULL;
+ dir[dirlen] = '\0';
# endif
dirlen = strlen (dir);
prev parent reply other threads:[~2023-01-30 22:12 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-01-30 4:09 Z/OS Enhancement to gnu lib Igor Todorovski
2023-01-30 11:48 ` Bruno Haible
2023-01-30 17:29 ` Igor Todorovski
2023-01-30 22:12 ` Bruno Haible [this message]
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
List information: https://lists.gnu.org/mailman/listinfo/bug-gnulib
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=2175144.6JPRsyc7qm@nimes \
--to=bruno@clisp.org \
--cc=bug-gnulib@gnu.org \
--cc=fultonm@ca.ibm.com \
--cc=itodorov@ca.ibm.com \
/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).