Skip to content

Commit bade6f9

Browse files
authored
fix: numerous vulnerabilities in native code (#940)
* fix(zds): Bounded copy for dsname, volser Signed-off-by: Trae Yelovich <trae.yelovich@broadcom.com> * fix(zutm): bounded copy for parms Signed-off-by: Trae Yelovich <trae.yelovich@broadcom.com> * fix(zut): fail in zut_bpxwdyn_common if parm larger than max len Signed-off-by: Trae Yelovich <trae.yelovich@broadcom.com> * fix(zdsm): rename macro to avoid collisions in C++ Signed-off-by: Trae Yelovich <trae.yelovich@broadcom.com> * fix(zut): off-by-one buffer overflow possibility Signed-off-by: Trae Yelovich <trae.yelovich@broadcom.com> * fix(zam24): Remove redundant BR R14 instruction Signed-off-by: Trae Yelovich <trae.yelovich@broadcom.com> * refactor(zds): Make etag copy more robust Signed-off-by: Trae Yelovich <trae.yelovich@broadcom.com> * fix(uss): unchecked indexing for CSV parse Signed-off-by: Trae Yelovich <trae.yelovich@broadcom.com> * fix(zds): avoid possible csifiltk overflow Signed-off-by: Trae Yelovich <trae.yelovich@broadcom.com> * fix(zds): Truncate error message for 31-bit alloc Signed-off-by: Trae Yelovich <trae.yelovich@broadcom.com> * fix(zds): avoid indexing UB in zds_is_valid_member_name Signed-off-by: Trae Yelovich <trae.yelovich@broadcom.com> * fix(zcn): 1-byte buffer overflow Signed-off-by: Trae Yelovich <trae.yelovich@broadcom.com> * fix(zcnm31): command text overflow for MGCRE Signed-off-by: Trae Yelovich <trae.yelovich@broadcom.com> * refactor: ZDIAG_SET_MSG helper to avoid overflow Signed-off-by: Trae Yelovich <trae.yelovich@broadcom.com> * fix(zusf): avoid argv option injection Signed-off-by: Trae Yelovich <trae.yelovich@broadcom.com> * fix(zjson): Depth cap of 64 for recursive branches Signed-off-by: Trae Yelovich <trae.yelovich@broadcom.com> * fix(zlogger): buffer overflow possibilities Signed-off-by: Trae Yelovich <trae.yelovich@broadcom.com> * fix(zcnm31): clamp length variables Signed-off-by: Trae Yelovich <trae.yelovich@broadcom.com> * refactor(ztype): remove do/while trick from ZDIAG_SET_MSG Signed-off-by: Trae Yelovich <trae.yelovich@broadcom.com> * fix(zjbm): Missing return in ZJBMEMSG Signed-off-by: Trae Yelovich <trae.yelovich@broadcom.com> * fix(zjbm): avoid buffer overflow for str copy Signed-off-by: Trae Yelovich <trae.yelovich@broadcom.com> * fix: use safe format strings Signed-off-by: Trae Yelovich <trae.yelovich@broadcom.com> * fix(zutm): remove unused var Signed-off-by: Trae Yelovich <trae.yelovich@broadcom.com> * chore: changelog Signed-off-by: Trae Yelovich <trae.yelovich@broadcom.com> * fix(zjbm): remove one param from ZDIAG_SET_MSG Signed-off-by: Trae Yelovich <trae.yelovich@broadcom.com> * fix: update link, use dynamic formatting Signed-off-by: Trae Yelovich <trae.yelovich@broadcom.com> * fix(zjbm): Change int param to pointer Signed-off-by: Trae Yelovich <trae.yelovich@broadcom.com> * chore: add comments on truncation cases Signed-off-by: Trae Yelovich <trae.yelovich@broadcom.com> * refactor(zutm): dynamic precision for parms Signed-off-by: Trae Yelovich <trae.yelovich@broadcom.com> * fix(zds): add precision to diag msg Signed-off-by: Trae Yelovich <trae.yelovich@broadcom.com> * fix(zds): add 7-byte padding to kept struct dword aligned Signed-off-by: Trae Yelovich <trae.yelovich@broadcom.com> --------- Signed-off-by: Trae Yelovich <trae.yelovich@broadcom.com>
1 parent db1ee73 commit bade6f9

21 files changed

Lines changed: 405 additions & 296 deletions

native/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ Check [Keep a Changelog](http://keepachangelog.com/) for recommendations on how
66

77
## Recent Changes
88

9+
- `c`: Fixed several vulnerabilities in C++ and Metal C code to improve stability. [#940](https://github.com/zowe/zowex/pull/940)
910
- **Breaking:** `c`: Refactored the backend for copying data sets to use Z/OS utilities IEBCOPY and IEBGENER. Removed `--delete-target-members` flag and added `--overwrite` flag for copying a partitioned data set to an existing partitioned data set. Removed duplicate `member_exists_in_pds` function. [#932] (https://github.com/zowe/zowex/issues/932)
1011
- `c`: Fix spool read / dynalloc error via optimization assignments. [#945](https://github.com/zowe/zowex/issues/945)
1112
- `c`: Updated `zut_read_input` so that all tests pass on `zowex`. Now there is no specific handling for line-based TTY input so that data is more consistently preserved.[#953](https://github.com/zowe/zowex/pull/953)

native/c/commands/uss.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,12 @@ int handle_uss_list(InvocationContext &context)
213213
fields.push_back(field);
214214
}
215215

216+
// We should have 8 fields: mode, links, user, group, size, filetag, mtime, name
217+
if (fields.size() < 8)
218+
{
219+
continue;
220+
}
221+
216222
entry->set("mode", str(fields[0]));
217223
entry->set("links", i64(atoi(fields[1].c_str())));
218224
entry->set("user", str(fields[2]));

native/c/zam.c

Lines changed: 32 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ static int handle_dcb_abend(ZDIAG *PTR32 diag, IO_CTRL *PTR32 ioc, const char *P
6363
if (0 == diag->e_msg_len)
6464
{
6565
strcpy(diag->service_name, operation);
66-
diag->e_msg_len = sprintf(diag->e_msg, "DCB abend during %s for %8.8s data set: %44.44s",
66+
ZDIAG_SET_MSG(diag, "DCB abend during %.16s for %8.8s data set: %44.44s",
6767
operation, ioc->ddname, ioc->jfcb.jfcbdsnm);
6868
diag->detail_rc = ZDS_RTNCD_DCB_ABEND_ERROR;
6969
}
@@ -78,15 +78,15 @@ static int validate_jfcb_attributes(ZDIAG *PTR32 diag, IO_CTRL *PTR32 ioc)
7878

7979
if (ioc->jfcb.jfcbind1 != jfcpds)
8080
{
81-
diag->e_msg_len = sprintf(diag->e_msg, "DDname: %8.8s data set: %44.44s is not a PDS: %X", ioc->dcb.dcbddnam, ioc->jfcb.jfcbdsnm, ioc->jfcb.jfcbind1);
81+
ZDIAG_SET_MSG(diag, "DDname: %8.8s data set: %44.44s is not a PDS: %X", ioc->dcb.dcbddnam, ioc->jfcb.jfcbdsnm, ioc->jfcb.jfcbind1);
8282
diag->detail_rc = ZDS_RTNCD_UNSUPPORTED_DATA_SET;
8383
return RTNCD_FAILURE;
8484
}
8585

8686
// ensure member name (e.g. is a partitioned data set)
8787
if (ioc->jfcb.jfcbelnm[0] == ' ')
8888
{
89-
diag->e_msg_len = sprintf(diag->e_msg, "DDname: %8.8s data set: %44.44s is not a partitioned data set: %s", ioc->dcb.dcbddnam, ioc->jfcb.jfcbdsnm, ioc->jfcb.jfcbelnm);
89+
ZDIAG_SET_MSG(diag, "DDname: %8.8s data set: %44.44s is not a partitioned data set: %.8s", ioc->dcb.dcbddnam, ioc->jfcb.jfcbdsnm, ioc->jfcb.jfcbelnm);
9090
diag->detail_rc = ZDS_RTNCD_UNSUPPORTED_DSORG;
9191
return RTNCD_FAILURE;
9292
}
@@ -107,7 +107,7 @@ static int enq_data_set(ZDIAG *PTR32 diag, IO_CTRL *PTR32 ioc)
107107
{
108108
diag->service_rc = rc;
109109
strcpy(diag->service_name, "ENQ");
110-
diag->e_msg_len = sprintf(diag->e_msg, "Failed to ENQ ddname: %8.8s data set: %44.44s rc was: %d", ioc->dcb.dcbddnam, ioc->jfcb.jfcbdsnm, rc);
110+
ZDIAG_SET_MSG(diag, "Failed to ENQ ddname: %8.8s data set: %44.44s rc was: %d", ioc->dcb.dcbddnam, ioc->jfcb.jfcbdsnm, rc);
111111
diag->detail_rc = ZDS_RTNCD_ENQ_ERROR;
112112
return RTNCD_FAILURE;
113113
}
@@ -147,7 +147,7 @@ static int get_ucb(ZDIAG *PTR32 diag, IO_CTRL *PTR32 ioc)
147147
if (0 == ioc->ucb)
148148
{
149149
diag->detail_rc = ZDS_RTNCD_UCB_ERROR;
150-
diag->e_msg_len = sprintf(diag->e_msg, "Failed to get UCB for data set: %44.44s", ioc->jfcb.jfcbdsnm);
150+
ZDIAG_SET_MSG(diag, "Failed to get UCB for data set: %44.44s", ioc->jfcb.jfcbdsnm);
151151
return RTNCD_FAILURE;
152152
}
153153

@@ -167,7 +167,7 @@ static int reserve_data_set(ZDIAG *PTR32 diag, IO_CTRL *PTR32 ioc)
167167
{
168168
diag->service_rc = rc;
169169
strcpy(diag->service_name, "RESERVE");
170-
diag->e_msg_len = sprintf(diag->e_msg, "Failed to RESERVE ddname: %8.8s data set: %44.44s rc was: %d", ioc->dcb.dcbddnam, ioc->jfcb.jfcbdsnm, rc);
170+
ZDIAG_SET_MSG(diag, "Failed to RESERVE ddname: %8.8s data set: %44.44s rc was: %d", ioc->dcb.dcbddnam, ioc->jfcb.jfcbdsnm, rc);
171171
diag->detail_rc = ZDS_RTNCD_RESERVE_ERROR;
172172
return RTNCD_FAILURE;
173173
}
@@ -184,7 +184,7 @@ static int open_data_set(ZDIAG *PTR32 diag, IO_CTRL *PTR32 ioc)
184184
{
185185
diag->service_rc = rc;
186186
strcpy(diag->service_name, "OPEN");
187-
diag->e_msg_len = sprintf(diag->e_msg, "Failed to open ddname: %8.8s for data set: %44.44s rc was: %d", ioc->dcb.dcbddnam, ioc->jfcb.jfcbdsnm, rc);
187+
ZDIAG_SET_MSG(diag, "Failed to open ddname: %8.8s for data set: %44.44s rc was: %d", ioc->dcb.dcbddnam, ioc->jfcb.jfcbdsnm, rc);
188188
diag->detail_rc = ZDS_RTNCD_OPEN_ERROR;
189189
return RTNCD_FAILURE;
190190
}
@@ -196,7 +196,7 @@ static int open_data_set(ZDIAG *PTR32 diag, IO_CTRL *PTR32 ioc)
196196

197197
if (!(ioc->dcb.dcboflgs & dcbofopn))
198198
{
199-
diag->e_msg_len = sprintf(diag->e_msg, "Data set is not open: %44.44s", ioc->jfcb.jfcbdsnm);
199+
ZDIAG_SET_MSG(diag, "Data set is not open: %44.44s", ioc->jfcb.jfcbdsnm);
200200
diag->detail_rc = ZDS_RTNCD_NOT_OPEN_ERROR;
201201
return RTNCD_FAILURE;
202202
}
@@ -210,7 +210,7 @@ static int validate_dcb_attributes(ZDIAG *PTR32 diag, IO_CTRL *PTR32 ioc)
210210

211211
if (!(ioc->dcb.dcbrecfm & (dcbrecf | dcbrecv)))
212212
{
213-
diag->e_msg_len = sprintf(diag->e_msg, "Data set is not a fixed or variable record format: %X", ioc->dcb.dcbrecfm);
213+
ZDIAG_SET_MSG(diag, "Data set is not a fixed or variable record format: %X", ioc->dcb.dcbrecfm);
214214
diag->detail_rc = ZDS_RTNCD_UNSUPPORTED_RECFM;
215215
return RTNCD_FAILURE;
216216
}
@@ -219,7 +219,7 @@ static int validate_dcb_attributes(ZDIAG *PTR32 diag, IO_CTRL *PTR32 ioc)
219219

220220
if (block_size < 1)
221221
{
222-
diag->e_msg_len = sprintf(diag->e_msg, "Data set has less than 1 block size: %X", block_size);
222+
ZDIAG_SET_MSG(diag, "Data set has less than 1 block size: %X", block_size);
223223
diag->detail_rc = ZDS_RTNCD_UNSUPPORTED_BLOCK_SIZE;
224224
return RTNCD_FAILURE;
225225
}
@@ -231,7 +231,7 @@ static int validate_dcb_attributes(ZDIAG *PTR32 diag, IO_CTRL *PTR32 ioc)
231231
// Fixed-length record validation
232232
if (block_size % ioc->dcb.dcblrecl != 0)
233233
{
234-
diag->e_msg_len = sprintf(diag->e_msg, "Data set block size is not a multiple of the record length: %d not evenly divisible by %d", ioc->dcb.dcbblksi, ioc->dcb.dcblrecl);
234+
ZDIAG_SET_MSG(diag, "Data set block size is not a multiple of the record length: %d not evenly divisible by %d", ioc->dcb.dcbblksi, ioc->dcb.dcblrecl);
235235
diag->detail_rc = ZDS_RTNCD_INVALID_BLOCK_SIZE;
236236
return RTNCD_FAILURE;
237237
}
@@ -241,7 +241,7 @@ static int validate_dcb_attributes(ZDIAG *PTR32 diag, IO_CTRL *PTR32 ioc)
241241
// Variable-length record validation: block size must be >= LRECL + 4 (for BDW)
242242
if (block_size < ioc->dcb.dcblrecl + sizeof(BDW))
243243
{
244-
diag->e_msg_len = sprintf(diag->e_msg, "Data set block size is too small for variable records: %d < %d (LRECL + 4)", block_size, ioc->dcb.dcblrecl + sizeof(BDW));
244+
ZDIAG_SET_MSG(diag, "Data set block size is too small for variable records: %d < %d (LRECL + 4)", block_size, ioc->dcb.dcblrecl + sizeof(BDW));
245245
diag->detail_rc = ZDS_RTNCD_INVALID_BLOCK_SIZE;
246246
return RTNCD_FAILURE;
247247
}
@@ -263,7 +263,7 @@ static int note_member(ZDIAG *PTR32 diag, IO_CTRL *PTR32 ioc, NOTE_RESPONSE *PTR
263263
{
264264
diag->service_rc = rc;
265265
strcpy(diag->service_name, "NOTE");
266-
diag->e_msg_len = sprintf(diag->e_msg, "Failed to NOTE ddname: %8.8s data set: %44.44s rc was: %d", ioc->ddname, ioc->jfcb.jfcbdsnm, rc);
266+
ZDIAG_SET_MSG(diag, "Failed to NOTE ddname: %8.8s data set: %44.44s rc was: %d", ioc->ddname, ioc->jfcb.jfcbdsnm, rc);
267267
diag->detail_rc = ZDS_RTNCD_NOTE_ERROR;
268268
}
269269
}
@@ -303,7 +303,7 @@ int open_input_vsam(ZDIAG *PTR32 diag, IO_CTRL *PTR32 *PTR32 ioc, const char *PT
303303
{
304304
diag->detail_rc = ZDS_RTNCD_SERVICE_FAILURE;
305305
strcpy(diag->service_name, "MODCB");
306-
diag->e_msg_len = sprintf(diag->e_msg, "MODCB failed rc was: %d rsn was: %d", rc, rsn);
306+
ZDIAG_SET_MSG(diag, "MODCB failed rc was: %d rsn was: %d", rc, rsn);
307307
diag->service_rc = rc;
308308
diag->service_rsn = rsn;
309309
return RTNCD_FAILURE;
@@ -314,7 +314,7 @@ int open_input_vsam(ZDIAG *PTR32 diag, IO_CTRL *PTR32 *PTR32 ioc, const char *PT
314314
{
315315
diag->detail_rc = ZDS_RTNCD_SERVICE_FAILURE;
316316
strcpy(diag->service_name, "OPEN");
317-
diag->e_msg_len = sprintf(diag->e_msg, "Failed to open acb rc was: %d", rc);
317+
ZDIAG_SET_MSG(diag, "Failed to open acb rc was: %d", rc);
318318
diag->service_rc = rc;
319319
return RTNCD_FAILURE;
320320
}
@@ -341,7 +341,7 @@ int point_input_vsam(ZDIAG *PTR32 diag, IO_CTRL *PTR32 ioc, TIME_STRUCT *time_st
341341
{
342342
diag->detail_rc = ZDS_RTNCD_SERVICE_FAILURE;
343343
strcpy(diag->service_name, "CONVTOD");
344-
diag->e_msg_len = sprintf(diag->e_msg, "Failed to CONVTOD rc was: %d", rc);
344+
ZDIAG_SET_MSG(diag, "Failed to CONVTOD rc was: %d", rc);
345345
diag->service_rc = rc;
346346
return rc;
347347
}
@@ -358,7 +358,7 @@ int point_input_vsam(ZDIAG *PTR32 diag, IO_CTRL *PTR32 ioc, TIME_STRUCT *time_st
358358
{
359359
diag->detail_rc = ZDS_RTNCD_SERVICE_FAILURE;
360360
strcpy(diag->service_name, "POINT");
361-
diag->e_msg_len = sprintf(diag->e_msg, "Failed to POINT rc was: %d", rc);
361+
ZDIAG_SET_MSG(diag, "Failed to POINT rc was: %d", rc);
362362
diag->service_rc = rc;
363363
return rc;
364364
}
@@ -392,7 +392,7 @@ int read_input_vsam(ZDIAG *PTR32 diag, IO_CTRL *PTR32 ioc)
392392
diag->detail_rc = ZDS_RTNCD_SERVICE_FAILURE;
393393
strcpy(diag->service_name, "GET");
394394
memcpy(rplrdbk, &rplp->rplfdbwd.rplfdbk, sizeof(rplrdbk));
395-
diag->e_msg_len = sprintf(diag->e_msg, "Failed to GET rc was: %d, RPLRDBK was: %02X%02X%02X", rc, rplrdbk[0], rplrdbk[1], rplrdbk[2]);
395+
ZDIAG_SET_MSG(diag, "Failed to GET rc was: %d, RPLRDBK was: %02X%02X%02X", rc, rplrdbk[0], rplrdbk[1], rplrdbk[2]);
396396
diag->service_rc = rc;
397397
return rc;
398398
}
@@ -410,7 +410,7 @@ int close_input_vsam(ZDIAG *PTR32 diag, IO_CTRL *PTR32 ioc)
410410
{
411411
diag->detail_rc = ZDS_RTNCD_SERVICE_FAILURE;
412412
strcpy(diag->service_name, "CLOSE");
413-
diag->e_msg_len = sprintf(diag->e_msg, "Failed to close acb rc was: %d", rc);
413+
ZDIAG_SET_MSG(diag, "Failed to close acb rc was: %d", rc);
414414
diag->service_rc = rc;
415415
return RTNCD_FAILURE;
416416
}
@@ -454,7 +454,7 @@ int open_output_bpam(ZDIAG *PTR32 diag, IO_CTRL *PTR32 *PTR32 ioc, const char *P
454454
{
455455
diag->detail_rc = ZDS_RTNCD_SERVICE_FAILURE;
456456
strcpy(diag->service_name, "RDJFCB");
457-
diag->e_msg_len = sprintf(diag->e_msg, "Failed to read output JFCB rc was: %d", rc);
457+
ZDIAG_SET_MSG(diag, "Failed to read output JFCB rc was: %d", rc);
458458
diag->service_rc = rc;
459459
return RTNCD_FAILURE;
460460
}
@@ -559,7 +559,7 @@ static int handle_fixed_record(ZDIAG *PTR32 diag, IO_CTRL *PTR32 ioc, const char
559559

560560
if (0 != rc)
561561
{
562-
diag->e_msg_len = sprintf(diag->e_msg, "Failed to write record rc was: %d", rc);
562+
ZDIAG_SET_MSG(diag, "Failed to write record rc was: %d", rc);
563563
diag->detail_rc = ZDS_RTNCD_SERVICE_FAILURE;
564564
diag->service_rc = rc;
565565
return RTNCD_FAILURE;
@@ -607,7 +607,7 @@ static int write_variable_record(ZDIAG *PTR32 diag, IO_CTRL *PTR32 ioc, const ch
607607

608608
if (0 != rc)
609609
{
610-
diag->e_msg_len = sprintf(diag->e_msg, "Failed to write record rc was: %d", rc);
610+
ZDIAG_SET_MSG(diag, "Failed to write record rc was: %d", rc);
611611
diag->detail_rc = ZDS_RTNCD_SERVICE_FAILURE;
612612
diag->service_rc = rc;
613613
return RTNCD_FAILURE;
@@ -626,7 +626,8 @@ static void copy_variable_record(IO_CTRL *PTR32 ioc, const char *PTR32 data, int
626626
ioc->lines_written++;
627627
RDW *PTR32 rdw_ptr = (RDW * PTR32) ioc->free_location;
628628
rdw_ptr->unused = 0;
629-
rdw_ptr->len = sprintf(ioc->free_location + sizeof(RDW), "%.*s", length, data) + sizeof(RDW);
629+
memcpy(ioc->free_location + sizeof(RDW), data, length);
630+
rdw_ptr->len = length + sizeof(RDW);
630631
ioc->bytes_in_buffer += rdw_ptr->len;
631632
ioc->free_location += rdw_ptr->len;
632633
}
@@ -736,7 +737,7 @@ static int write_flush(ZDIAG *PTR32 diag, IO_CTRL *PTR32 ioc)
736737

737738
if (0 != rc)
738739
{
739-
diag->e_msg_len = sprintf(diag->e_msg, "Failed to write record rc was: %d", rc);
740+
ZDIAG_SET_MSG(diag, "Failed to write record rc was: %d", rc);
740741
diag->detail_rc = ZDS_RTNCD_SERVICE_FAILURE;
741742
diag->service_rc = rc;
742743
return RTNCD_FAILURE;
@@ -763,7 +764,7 @@ static int bldl_member(ZDIAG *PTR32 diag, IO_CTRL *PTR32 ioc, BLDL_PL *PTR32 bld
763764
{
764765
diag->service_rc = rc;
765766
strcpy(diag->service_name, "BLDL");
766-
diag->e_msg_len = sprintf(diag->e_msg, "Failed to BLDL ddname: %8.8s data set: %44.44s rc was: %d", ioc->ddname, ioc->jfcb.jfcbdsnm, rc);
767+
ZDIAG_SET_MSG(diag, "Failed to BLDL ddname: %8.8s data set: %44.44s rc was: %d", ioc->ddname, ioc->jfcb.jfcbdsnm, rc);
767768
diag->detail_rc = ZDS_RTNCD_BLDL_ERROR;
768769
}
769770
return rc;
@@ -818,7 +819,7 @@ static int update_ispf_statistics(ZDIAG *PTR32 diag, IO_CTRL *PTR32 ioc)
818819
rc = zutm1gur(user);
819820
if (0 != rc)
820821
{
821-
diag->e_msg_len = sprintf(diag->e_msg, "Failed to get userid rc was: %d", rc);
822+
ZDIAG_SET_MSG(diag, "Failed to get userid rc was: %d", rc);
822823
diag->detail_rc = ZDS_RTNCD_SERVICE_FAILURE;
823824
diag->service_rc = rc;
824825
return RTNCD_FAILURE;
@@ -868,7 +869,7 @@ static int update_ispf_statistics(ZDIAG *PTR32 diag, IO_CTRL *PTR32 ioc)
868869
rc = zutm1gur(user);
869870
if (0 != rc)
870871
{
871-
diag->e_msg_len = sprintf(diag->e_msg, "Failed to get userid rc was: %d", rc);
872+
ZDIAG_SET_MSG(diag, "Failed to get userid rc was: %d", rc);
872873
diag->detail_rc = ZDS_RTNCD_SERVICE_FAILURE;
873874
diag->service_rc = rc;
874875
return RTNCD_FAILURE;
@@ -922,7 +923,7 @@ static int stow_data_set(ZDIAG *PTR32 diag, IO_CTRL *PTR32 ioc)
922923
{
923924
diag->service_rc = rc;
924925
strcpy(diag->service_name, "STOW");
925-
diag->e_msg_len = sprintf(diag->e_msg, "Failed to STOW ISPF statistics: %8.8s data set: %44.44s rsn was: %d", ioc->ddname, ioc->jfcb.jfcbdsnm, rsn);
926+
ZDIAG_SET_MSG(diag, "Failed to STOW ISPF statistics: %8.8s data set: %44.44s rsn was: %d", ioc->ddname, ioc->jfcb.jfcbdsnm, rsn);
926927
diag->detail_rc = ZDS_RTNCD_STOW_ERROR;
927928
}
928929
}
@@ -946,7 +947,7 @@ static int close_data_set(ZDIAG *PTR32 diag, IO_CTRL *PTR32 ioc)
946947
{
947948
diag->service_rc = rc;
948949
strcpy(diag->service_name, "CLOSE");
949-
diag->e_msg_len = sprintf(diag->e_msg, "Failed to close ddname: %8.8s data set: %44.44s rc was: %d", ioc->ddname, ioc->jfcb.jfcbdsnm, rc);
950+
ZDIAG_SET_MSG(diag, "Failed to close ddname: %8.8s data set: %44.44s rc was: %d", ioc->ddname, ioc->jfcb.jfcbdsnm, rc);
950951
diag->detail_rc = ZDS_RTNCD_CLOSE_ERROR;
951952
}
952953
}
@@ -969,7 +970,7 @@ static int deq_reserve_data_set(ZDIAG *PTR32 diag, IO_CTRL *PTR32 ioc)
969970
{
970971
diag->service_rc = rc;
971972
strcpy(diag->service_name, "DEQ RESERVE");
972-
diag->e_msg_len = sprintf(diag->e_msg, "Failed to DEQ RESERVE ddname: %8.8s data set: %44.44s rc was: %d", ioc->ddname, ioc->jfcb.jfcbdsnm, rc);
973+
ZDIAG_SET_MSG(diag, "Failed to DEQ RESERVE ddname: %8.8s data set: %44.44s rc was: %d", ioc->ddname, ioc->jfcb.jfcbdsnm, rc);
973974
diag->detail_rc = ZDS_RTNCD_DEQ_RESERVE_ERROR;
974975
}
975976
return rc;
@@ -995,7 +996,7 @@ static int deq_data_set(ZDIAG *PTR32 diag, IO_CTRL *PTR32 ioc)
995996
{
996997
diag->service_rc = rc;
997998
strcpy(diag->service_name, "DEQ");
998-
diag->e_msg_len = sprintf(diag->e_msg, "Failed to DEQ ddname: %8.8s data set: %44.44s rc was: %d", ioc->ddname, ioc->jfcb.jfcbdsnm, rc);
999+
ZDIAG_SET_MSG(diag, "Failed to DEQ ddname: %8.8s data set: %44.44s rc was: %d", ioc->ddname, ioc->jfcb.jfcbdsnm, rc);
9991000
diag->detail_rc = ZDS_RTNCD_DEQ_ERROR;
10001001
}
10011002
}

native/c/zam24.s

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ ENTRY24 DS 0H
2424
OILH R15,X'8000' Set AMODE 31 bit for BASSM
2525
LA R1,WORK -> IO_CTRL "work" field
2626
BASSM 0,R15 Call ZAMDEXIT in AMODE 31
27-
BR R14 Return to system
2827
*
2928
CONSTANT DS 0D
3029
LTORG ,

native/c/zcn.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ int zcn_activate(ZCN *zcn, const std::string &console_name)
2626
int rc = 0;
2727
zcn->diag.detail_rc = 0;
2828

29-
strcpy(zcn->eye, ZCN_EYE);
29+
memcpy(zcn->eye, ZCN_EYE, sizeof(zcn->eye));
3030

3131
zut_uppercase_pad_truncate(zcn->console_name, console_name, sizeof(zcn->console_name));
3232

@@ -56,7 +56,7 @@ int zcn_put(ZCN *zcn, const std::string &command)
5656
char *command31 = (char *)__malloc31(command.length() + 1);
5757
if (command31 == nullptr)
5858
{
59-
zcn->diag.e_msg_len = sprintf(zcn->diag.e_msg, "Failed to allocate 31-bit memory for command: %s", command.c_str());
59+
ZDIAG_SET_MSG(&zcn->diag, "Failed to allocate 31-bit memory for command: %s", command.c_str());
6060
return RTNCD_FAILURE;
6161
}
6262
memset(command31, 0x00, command.length() + 1);
@@ -86,7 +86,7 @@ int zcn_get(ZCN *zcn, std::string &response)
8686
char *resp31 = (char *)__malloc31(zcn->buffer_size);
8787
if (resp31 == nullptr)
8888
{
89-
zcn->diag.e_msg_len = sprintf(zcn->diag.e_msg, "Failed to allocate 31-bit memory for response");
89+
ZDIAG_SET_MSG(&zcn->diag, "Failed to allocate 31-bit memory for response");
9090
return RTNCD_FAILURE;
9191
}
9292
memset(resp31, 0x00, zcn->buffer_size);

0 commit comments

Comments
 (0)