From: Bruno Haible Date: Mon, 30 Jan 2023 22:10:21 +0000 (+0100) Subject: at-internal: Fix support for z/OS. X-Git-Url: https://gitweb.git.savannah.gnu.org/gitweb/?a=commitdiff_plain;h=b6c3e70cdaa5956d6bd03a4d32ddbcef45511864;p=gnulib.git 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/ChangeLog b/ChangeLog index 31248afabe..0a90e3bd59 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,9 @@ 2023-01-30 Bruno Haible + 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. + at-internal: Add support for z/OS. Reported and draft patch by Igor Todorovski . * lib/openat-proc.c [z/OS]: Include . 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);