diff options
| author | Sean Kurtz <seankurtz75@gmail.com> | 2026-11-18 10:09:15 -0600 |
|---|---|---|
| committer | Sean Kurtz <seankurtz75@gmail.com> | 2026-11-18 10:09:15 -0600 |
| commit | 3fc7967c5df616e924ff189b6136cae4eca281bc (patch) | |
| tree | 6ea712a987128cd2b5d3be803cb16c034cafc8c6 /src | |
| parent | b4d6bf138d7843d5ed497f2fb67917319c773e96 (diff) | |
| download | zash-3fc7967c5df616e924ff189b6136cae4eca281bc.tar.gz | |
sys_info: return empty when an MVS control block is absent
CVT, ASCB and now ECVT were dereferenced without a check; a null there
would be an S0C4 in 'sysinfo', in 'read -t' timeouts and at job-table
refresh. A shell may run where PSAAOLD or the ECVT pointer is not set,
so report an empty field as sys_info() already does for a null job name.
Diffstat (limited to 'src')
| -rw-r--r-- | src/sys_zos.c | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/src/sys_zos.c b/src/sys_zos.c index b524dc3..85dfe86 100644 --- a/src/sys_zos.c +++ b/src/sys_zos.c @@ -483,13 +483,21 @@ const char *sys_info(sys_info_kind kind) { static char buf[32]; const unsigned char *cvt = ptr31(0x10); const unsigned char *ascb = ptr31(0x224); + /* Both are always there under TSO and batch, but a bad address here + * would be an S0C4 in the most visible place a shell has. */ + if (!cvt || !ascb) + return ""; switch (kind) { case SI_SYSNAME: mvs_name(cvt + 0x154, 8, buf); break; - case SI_SYSPLEX: - mvs_name(ptr31((uintptr_t)(cvt + 0x8c)) + 8, 8, buf); + case SI_SYSPLEX: { + const unsigned char *ecvt = ptr31((uintptr_t)(cvt + 0x8c)); + if (!ecvt) + return ""; + mvs_name(ecvt + 8, 8, buf); break; + } case SI_RELEASE: { struct utsname u; if (__osname(&u) < 0) |
