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.
+
at-internal: Add support for z/OS.
Reported and draft patch by Igor Todorovski <itodorov@ca.ibm.com>.
* lib/openat-proc.c [z/OS]: Include <termios.h>.
# 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);