From e3f1c3b6e2d3db30a1ca1efd2d5d5cd3bcc5e238 Mon Sep 17 00:00:00 2001 From: Martin Zeithaml Date: Wed, 7 Aug 2024 08:55:53 +0200 Subject: [PATCH 1/8] Minor debug message change Signed-off-by: Martin Zeithaml --- c/httpserver.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/c/httpserver.c b/c/httpserver.c index c3cf7d9c5..214309649 100644 --- a/c/httpserver.c +++ b/c/httpserver.c @@ -2913,8 +2913,8 @@ int extractBearerToken(HttpRequest *request, HttpHeader *authHeader) { AUTH_TRACE("start tokenEnd loop\n"); while ((tokenEnd < headerLength) && (ebcdicHeader[tokenEnd] > 0x041)){ tokenEnd++; - zowelog(NULL, LOG_COMP_HTTPSERVER, ZOWE_LOG_DEBUG3, "tokenEnd=%d\n", tokenEnd); } + zowelog(NULL, LOG_COMP_HTTPSERVER, ZOWE_LOG_DEBUG3, "tokenEnd=%d\n", tokenEnd); const int tokenLen = tokenEnd - tokenStart; AUTH_TRACE("bearer token length = %d\n", tokenLen); From 915291f55424223e55e09788b873f3957977eedd Mon Sep 17 00:00:00 2001 From: Martin Zeithaml Date: Wed, 7 Aug 2024 09:07:03 +0200 Subject: [PATCH 2/8] Move debug3 message out of the loop Signed-off-by: Martin Zeithaml --- c/httpserver.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/c/httpserver.c b/c/httpserver.c index 214309649..6b8ae8e77 100644 --- a/c/httpserver.c +++ b/c/httpserver.c @@ -2846,9 +2846,9 @@ int extractBasicAuth(HttpRequest *request, HttpHeader *authHeader){ char *authString = NULL; AUTH_TRACE("start authEnd loop\n"); while ((authEnd < headerLength) && (ebcdicHeader[authEnd] > 0x041)){ - zowelog(NULL, LOG_COMP_HTTPSERVER, ZOWE_LOG_DEBUG3, "authEnd=%d\n",authEnd); authEnd++; } + zowelog(NULL, LOG_COMP_HTTPSERVER, ZOWE_LOG_DEBUG3, "authEnd=%d\n",authEnd); authLen = authEnd-authStart; encodedAuthString = SLHAlloc(slh,authLen+1); authString = SLHAlloc(slh,authLen+1); From d4e2b6209670c0d37e6f7c27aec3d4b5b8d007f1 Mon Sep 17 00:00:00 2001 From: Zowe Robot Date: Wed, 7 Aug 2024 07:14:56 +0000 Subject: [PATCH 3/8] Update changelog with PR #471 description Signed-off-by: Zowe Robot --- CHANGELOG.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 48b28cf58..e26e23420 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,8 @@ # Zowe Common C Changelog +## `2.18.0` +- Minor `components.zss.logLevels._zss.httpserver=5` debug messages enhancement (#471) + ## `2.17.0` - Fixed `xplatform.loadFileUTF8` when trying to open nonexistent file (#454) - Bugfix: fix an incorrect check in the recovery router code which might lead to From 352528b56d05a35a896d9fbb118215000a368a41 Mon Sep 17 00:00:00 2001 From: Irek Fakhrutdinov Date: Fri, 16 Aug 2024 23:02:32 +0200 Subject: [PATCH 4/8] IARV64 results need to be checked for 0x7FFFF000 When MEMLIMIT is reached, IARV64 GETSTOR returns 0x7FFFF000; this conditions needs to be checked before memsetting. Fixes: #474 Signed-off-by: Irek Fakhrutdinov --- CHANGELOG.md | 3 +++ c/alloc.c | 14 ++++++++++++-- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e0f34ee90..ed13c6370 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,8 @@ # Zowe Common C Changelog +## `2.18.1` +- Bugfix: IARV64 results must be checked for 0x7FFFF000 (#474) + ## `2.18.0` - Minor `components.zss.logLevels._zss.httpserver=5` debug messages enhancement (#471) diff --git a/c/alloc.c b/c/alloc.c index 33742901a..b75b2fecf 100644 --- a/c/alloc.c +++ b/c/alloc.c @@ -181,7 +181,12 @@ static char* __ptr64 getmain64(long long sizeInMegabytes, int *returnCode, int * if (returnCode) *returnCode = macroRetCode; if (reasonCode) *reasonCode = macroResCode; - + + // IARV64 returns 0x7FFFF000 when MEMLIMIT is reached + if (data == (void *)0x7FFFF000) { + data = NULL; + } + return data; } @@ -202,7 +207,12 @@ static char* __ptr64 getmain64ByToken(long long sizeInMegabytes, long long token if (returnCode) *returnCode = macroRetCode; if (reasonCode) *reasonCode = macroResCode; - + + // IARV64 returns 0x7FFFF000 when MEMLIMIT is reached + if (data == (void *)0x7FFFF000) { + data = NULL; + } + return data; } From 8698212b96683b2d46df60b2ea138b11fc3bb6ce Mon Sep 17 00:00:00 2001 From: Irek Fakhrutdinov Date: Fri, 16 Aug 2024 23:23:14 +0200 Subject: [PATCH 5/8] SLHAlloc must return NULL when internal allocations fail The SLHAlloc function keeps using the results of the internal allocations even when they're NULL which leads to S0C4 ABENDs. This commit makes SLHAlloc return NULL when the internal allocations fail. Signed-off-by: Irek Fakhrutdinov --- CHANGELOG.md | 1 + c/utils.c | 2 ++ 2 files changed, 3 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index ed13c6370..18c77e22d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ ## `2.18.1` - Bugfix: IARV64 results must be checked for 0x7FFFF000 (#474) +- Bugfix: SLH should not ABEND when MEMLIMIT is reached (additional NULL check) ## `2.18.0` - Minor `components.zss.logLevels._zss.httpserver=5` debug messages enhancement (#471) diff --git a/c/utils.c b/c/utils.c index a1feb7c6e..b48b1268f 100644 --- a/c/utils.c +++ b/c/utils.c @@ -1502,6 +1502,7 @@ char *SLHAlloc(ShortLivedHeap *slh, int size){ safeMalloc31(size+4,"SLH Oversize Extend")); if (bigBlock == NULL){ reportSLHFailure(slh,size); + return NULL; } int *sizePtr = (int*)bigBlock; *sizePtr = size; @@ -1528,6 +1529,7 @@ char *SLHAlloc(ShortLivedHeap *slh, int size){ safeMalloc31(slh->blockSize+4,"SLH Extend") ); if (data == NULL){ reportSLHFailure(slh,size); + return NULL; } int *sizePtr = (int*)data; *sizePtr = slh->blockSize; From 488a8e970a9e685728252f72ec7337b09f548066 Mon Sep 17 00:00:00 2001 From: Irek Fakhrutdinov Date: Mon, 3 Jun 2024 09:55:53 +0200 Subject: [PATCH 6/8] Add support for longer cross-memory server parameters This commit extends the config cross-memory service and cross-memory server's structures responsible for storing parameters to support parameter names and values longer than 72 and 128 characters respectively. Backward compatibility is provided by introducing and using a version field in the config service's parameter list. Fixes: zowe/zss#684 Signed-off-by: Irek Fakhrutdinov --- CHANGELOG.md | 2 + c/crossmemory.c | 193 +++++++++++++++++++++++++++++++++++++++++++----- h/crossmemory.h | 58 ++++++++++++++- 3 files changed, 235 insertions(+), 18 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 18c77e22d..a0fe357cf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,8 @@ ## `2.18.1` - Bugfix: IARV64 results must be checked for 0x7FFFF000 (#474) - Bugfix: SLH should not ABEND when MEMLIMIT is reached (additional NULL check) +- Bugfix: support cross-memory server parameters longer than 128 characters + (zowe/zss#684) ## `2.18.0` - Minor `components.zss.logLevels._zss.httpserver=5` debug messages enhancement (#471) diff --git a/c/crossmemory.c b/c/crossmemory.c index d7f132f17..5ddc6199e 100644 --- a/c/crossmemory.c +++ b/c/crossmemory.c @@ -43,6 +43,8 @@ #include "utils.h" #include "zvt.h" +#define CMS_STATIC_ASSERT($expr) typedef char p[($expr) ? 1 : -1] + #define CROSS_MEMORY_SERVER_MIN_NAME_LENGTH 4 #define CROSS_MEMORY_SERVER_MAX_NAME_LENGTH 16 @@ -598,12 +600,32 @@ typedef struct CrossMemoryServerConfigServiceParm_tag { char eyecatcher[8]; #define CMS_CONFIG_SERVICE_PARM_EYECATCHER "RSCMSCSY" char nameNullTerm[CMS_CONFIG_PARM_MAX_NAME_LENGTH + 1]; - char padding[7]; - CrossMemoryServerConfigParm result; + uint8_t version; +#define CMS_CONFIG_SERVICE_PARM_VERSION_0 0 +#define CMS_CONFIG_SERVICE_PARM_VERSION_2 2 +#define CMS_CONFIG_SERVICE_PARM_SIZE_V0 227 +#define CMS_CONFIG_SERVICE_PARM_SIZE_V2 227 +#define CMS_CONFIG_SERVICE_PARM_VERSION CMS_CONFIG_SERVICE_PARM_VERSION_2 + char padding[6]; + union { + CrossMemoryServerConfigParm result; + struct { // only for versions >= 2 + int32_t nameLength; + int32_t valueBufferLength; + PAD_LONG(0, const char *name); + PAD_LONG(1, void *valueBuffer); + CrossMemoryServerConfigParmExt result; + } ext; + }; } CrossMemoryServerConfigServiceParm; ZOWE_PRAGMA_PACK_RESET +CMS_STATIC_ASSERT(CMS_CONFIG_SERVICE_PARM_SIZE_V0 == + sizeof(CrossMemoryServerConfigServiceParm)); +CMS_STATIC_ASSERT(CMS_CONFIG_SERVICE_PARM_SIZE_V2 == + sizeof(CrossMemoryServerConfigServiceParm)); + static void initLogMessagePrefix(LogMessagePrefix *prefix) { LogTimestamp currentTime; getCurrentLogTimestamp(¤tTime); @@ -984,7 +1006,7 @@ int cmsAddConfigParm(CrossMemoryServer *server, ShortLivedHeap *slh = server->slh; size_t keyLength = strlen(name); - if (keyLength > CMS_CONFIG_PARM_MAX_NAME_LENGTH) { + if (keyLength > CMS_CONFIG_PARM_EXT_MAX_NAME_LENGTH) { return RC_CMS_CONFIG_PARM_NAME_TOO_LONG; } @@ -995,16 +1017,17 @@ int cmsAddConfigParm(CrossMemoryServer *server, strcpy(keyNullTerm, name); - CrossMemoryServerConfigParm *parm = - (CrossMemoryServerConfigParm *)SLHAlloc( + CrossMemoryServerConfigParmExt *parm = + (CrossMemoryServerConfigParmExt *)SLHAlloc( slh, - sizeof(CrossMemoryServerConfigParm) + sizeof(CrossMemoryServerConfigParmExt) ); if (parm == NULL) { return RC_CMS_SLH_ALLOC_FAILED; } - memcpy(parm->eyecatcher, CMS_PARM_EYECATCHER, sizeof(parm->eyecatcher)); + memcpy(parm->eyecatcher, CMS_CONFIG_PARM_EXT_EYECATCHER, + sizeof(parm->eyecatcher)); parm->type = type; switch (type) { @@ -1012,11 +1035,15 @@ int cmsAddConfigParm(CrossMemoryServer *server, { const char *charValueNullTerm = value; size_t valueLength = strlen(charValueNullTerm); - if (valueLength > sizeof(parm->charValueNullTerm) - 1) { + if (valueLength > CMS_CONFIG_PARM_EXT_MAX_VALUE_SIZE) { return RC_CMS_CHAR_PARM_TOO_LONG; } parm->valueLength = valueLength; - strcpy(parm->charValueNullTerm, charValueNullTerm); + parm->value = SLHAlloc(slh, valueLength + 1); + if (parm->value == NULL) { + return RC_CMS_SLH_ALLOC_FAILED; + } + strcpy(parm->value, charValueNullTerm); } break; default: @@ -1784,6 +1811,9 @@ static int handleConfigService(CrossMemoryServer *server, return RC_CMS_STDSVC_PARM_NULL; } + // Copying different versions using the same size is fine because both v0 and + // v2 have the same size, but, if this changes in the future, more complicated + // logic would need to be implemented. CrossMemoryServerConfigServiceParm localParm; cmCopyFromSecondaryWithCallerKey(&localParm, callerParm, sizeof(CrossMemoryServerConfigServiceParm)); @@ -1793,16 +1823,58 @@ static int handleConfigService(CrossMemoryServer *server, return RC_CMS_STDSVC_PARM_BAD_EYECATCHER; } - localParm.nameNullTerm[sizeof(localParm.nameNullTerm) - 1] = '\0'; - - CrossMemoryServerConfigParm *configParm = - htGet(server->configParms, localParm.nameNullTerm); - if (configParm == NULL) { - return RC_CMS_CONFIG_PARM_NOT_FOUND; + if (localParm.version != CMS_CONFIG_SERVICE_PARM_VERSION_0 && + localParm.version != CMS_CONFIG_SERVICE_PARM_VERSION_2) { + return RC_CMS_STDSVC_PARM_BAD_VERSION; } - cmCopyToSecondaryWithCallerKey(&callerParm->result, configParm, - sizeof(callerParm->result)); + if (localParm.version == CMS_CONFIG_SERVICE_PARM_VERSION_0) { + localParm.nameNullTerm[sizeof(localParm.nameNullTerm) - 1] = '\0'; + CrossMemoryServerConfigParmExt *configParm = htGet(server->configParms, + localParm.nameNullTerm); + if (configParm == NULL) { + return RC_CMS_CONFIG_PARM_NOT_FOUND; + } + size_t valueCopyLength = configParm->type == CMS_CONFIG_PARM_TYPE_CHAR ? + configParm->valueLength + 1 : configParm->valueLength; + if (valueCopyLength > sizeof(localParm.result.charValueNullTerm)) { + return RC_CMS_CONFIG_VALUE_BUF_TOO_SMALL; + } + localParm.result = (CrossMemoryServerConfigParm) { + .eyecatcher = CMS_PARM_EYECATCHER, + .valueLength = configParm->valueLength, + .type = configParm->type, + }; + memcpy(localParm.result.charValueNullTerm, configParm->value, + valueCopyLength); + cmCopyToSecondaryWithCallerKey(callerParm, &localParm, + CMS_CONFIG_SERVICE_PARM_SIZE_V0); + } else { + char nameLocalBuffer[CMS_CONFIG_PARM_EXT_MAX_NAME_LENGTH + 1]; + if (localParm.ext.nameLength > sizeof(nameLocalBuffer) - 1) { + return RC_CMS_CONFIG_PARM_NAME_TOO_LONG; + } + cmCopyFromSecondaryWithCallerKey(nameLocalBuffer, localParm.ext.name, + localParm.ext.nameLength); + nameLocalBuffer[localParm.ext.nameLength] = '\0'; + CrossMemoryServerConfigParmExt *configParm = htGet(server->configParms, + nameLocalBuffer); + if (configParm == NULL) { + return RC_CMS_CONFIG_PARM_NOT_FOUND; + } + size_t valueCopyLength = configParm->type == CMS_CONFIG_PARM_TYPE_CHAR ? + configParm->valueLength + 1 : configParm->valueLength; + localParm.ext.result = *configParm; + localParm.ext.result.value = localParm.ext.valueBuffer; + cmCopyToSecondaryWithCallerKey(callerParm, &localParm, + CMS_CONFIG_SERVICE_PARM_SIZE_V2); + if (valueCopyLength > localParm.ext.valueBufferLength) { + return RC_CMS_CONFIG_VALUE_BUF_TOO_SMALL; + } + cmCopyToSecondaryWithCallerKey(localParm.ext.valueBuffer, + configParm->value, + valueCopyLength); + } return RC_CMS_OK; } @@ -5335,6 +5407,7 @@ int cmsGetConfigParm(const CrossMemoryServerName *serverName, const char *name, memcpy(parmList.eyecatcher, CMS_CONFIG_SERVICE_PARM_EYECATCHER, sizeof(parmList.eyecatcher)); memcpy(parmList.nameNullTerm, name, nameLength); + parmList.version = CMS_CONFIG_SERVICE_PARM_VERSION_0; int serviceRC = cmsCallService( serverName, @@ -5364,6 +5437,7 @@ int cmsGetConfigParmUnchecked(const CrossMemoryServerName *serverName, memcpy(parmList.eyecatcher, CMS_CONFIG_SERVICE_PARM_EYECATCHER, sizeof(parmList.eyecatcher)); memcpy(parmList.nameNullTerm, name, nameLength); + parmList.version = CMS_CONFIG_SERVICE_PARM_VERSION_0; CrossMemoryServerGlobalArea *cmsGA = NULL; int getGlobalAreaRC = cmsGetGlobalArea(serverName, &cmsGA); @@ -5387,6 +5461,91 @@ int cmsGetConfigParmUnchecked(const CrossMemoryServerName *serverName, return RC_CMS_OK; } +int cmsGetConfigParmExt(const CrossMemoryServerName *serverName, + const char *name, + void *valueBuffer, + int valueBufferSize, + CrossMemoryServerConfigParmExt *parm, + int *rsn) { + + size_t nameLength = strlen(name); + if (nameLength > CMS_CONFIG_PARM_EXT_MAX_NAME_LENGTH) { + return RC_CMS_CONFIG_PARM_NAME_TOO_LONG; + } + + CrossMemoryServerConfigServiceParm parmList = { + .eyecatcher = CMS_CONFIG_SERVICE_PARM_EYECATCHER, + .version = CMS_CONFIG_SERVICE_PARM_VERSION, + .ext.nameLength = nameLength, + .ext.name = name, + .ext.valueBufferLength = valueBufferSize, + .ext.valueBuffer = valueBuffer, + }; + + int serviceRC = cmsCallService( + serverName, + CROSS_MEMORY_SERVER_CONFIG_SERVICE_ID, + &parmList, + rsn + ); + if (serviceRC != RC_CMS_OK) { + if (serviceRC == RC_CMS_CONFIG_VALUE_BUF_TOO_SMALL) { + *parm = parmList.ext.result; + } + return serviceRC; + } + + *parm = parmList.ext.result; + + return RC_CMS_OK; +} + +int cmsGetConfigParmExtUnchecked(const CrossMemoryServerName *serverName, + const char *name, + void *valueBuffer, + int valueBufferSize, + CrossMemoryServerConfigParmExt *parm, + int *rsn) { + + size_t nameLength = strlen(name); + if (nameLength > CMS_CONFIG_PARM_EXT_MAX_NAME_LENGTH) { + return RC_CMS_CONFIG_PARM_NAME_TOO_LONG; + } + + CrossMemoryServerConfigServiceParm parmList = { + .eyecatcher = CMS_CONFIG_SERVICE_PARM_EYECATCHER, + .version = CMS_CONFIG_SERVICE_PARM_VERSION, + .ext.nameLength = nameLength, + .ext.name = name, + .ext.valueBufferLength = valueBufferSize, + .ext.valueBuffer = valueBuffer, + }; + + CrossMemoryServerGlobalArea *cmsGA = NULL; + int getGlobalAreaRC = cmsGetGlobalArea(serverName, &cmsGA); + if (getGlobalAreaRC != RC_CMS_OK) { + return getGlobalAreaRC; + } + + int serviceRC = cmsCallService3( + cmsGA, + CROSS_MEMORY_SERVER_CONFIG_SERVICE_ID, + &parmList, + CMS_CALL_FLAG_NO_SAF_CHECK, + rsn + ); + if (serviceRC != RC_CMS_OK) { + if (serviceRC == RC_CMS_CONFIG_VALUE_BUF_TOO_SMALL) { + *parm = parmList.ext.result; + } + return serviceRC; + } + + *parm = parmList.ext.result; + + return RC_CMS_OK; +} + int cmsGetPCLogLevel(const CrossMemoryServerName *serverName) { int logLevel = ZOWE_LOG_NA; diff --git a/h/crossmemory.h b/h/crossmemory.h index 6fe0bad9e..aa4c14637 100644 --- a/h/crossmemory.h +++ b/h/crossmemory.h @@ -142,7 +142,9 @@ #define RC_CMS_NO_ROOM_FOR_CMS_GETTER 91 #define RC_CMS_LANC_NOT_LOCKED 92 #define RC_CMS_LANC_NOT_RELEASED 93 -#define RC_CMS_MAX_RC 93 +#define RC_CMS_STDSVC_PARM_BAD_VERSION 94 +#define RC_CMS_CONFIG_VALUE_BUF_TOO_SMALL 95 +#define RC_CMS_MAX_RC 95 extern const char *CMS_RC_DESCRIPTION[]; @@ -377,9 +379,11 @@ typedef struct CrossMemoryServerParmList_tag { PAD_LONG(1, void *callerData); } CrossMemoryServerParmList; +#pragma enum(1) typedef enum CrossMemoryServerParmType_tag { CMS_CONFIG_PARM_TYPE_CHAR } CrossMemoryServerParmType; +#pragma enum(reset) #define CMS_CONFIG_PARM_MAX_NAME_LENGTH 72 #define CMS_CONFIG_PARM_MAX_VALUE_SIZE 128 @@ -394,6 +398,19 @@ typedef struct CrossMemoryServerConfigParm_tag { }; } CrossMemoryServerConfigParm; +typedef struct CrossMemoryServerConfigParmExt_tag { + char eyecatcher[8]; +#define CMS_CONFIG_PARM_EXT_EYECATCHER "RSCMSCFX" + uint8_t version; +#define CMS_CONFIG_PARM_EXT_VERSION 1 + CrossMemoryServerParmType type; + char padding0[2]; +#define CMS_CONFIG_PARM_EXT_MAX_NAME_LENGTH 1024 +#define CMS_CONFIG_PARM_EXT_MAX_VALUE_SIZE INT32_MAX + int32_t valueLength; + PAD_LONG(0, void *value); +} CrossMemoryServerConfigParmExt; + typedef struct CrossMemoryServerStatus_tag { int cmsRC; char descriptionNullTerm[64]; @@ -424,6 +441,8 @@ ZOWE_PRAGMA_PACK_RESET #define cmsHexDump CMHEXDMP #define cmsGetConfigParm CMGETPRM #define cmsGetConfigParmUnchecked CMGETPRU +#define cmsGetConfigParmExt CMGETPRX +#define cmsGetConfigParmExtUnchecked CMGETPUX #define cmsGetPCLogLevel CMGETLOG #define cmsGetStatus CMGETSTS #define cmsMakeServerName CMMKSNAM @@ -559,6 +578,43 @@ int cmsGetConfigParm(const CrossMemoryServerName *serverName, const char *name, int cmsGetConfigParmUnchecked(const CrossMemoryServerName *serverName, const char *name, CrossMemoryServerConfigParm *parm); +/** + * @brief Get a parameter from the cross-memory server's PARMLIB + * @param[in] serverName Cross-memory server whose parameter is to be read + * @param[in] name Name of the parameter + * @param[out] valueBuffer Buffer for the result value + * @param[out] valueBufferSize Size of the value buffer + * @param[out] parm Result parameter entry + * @param[out] rsn Reason code provided by the service in case of a failure + * @return RC_CMS_OK in case of success, and one of the RC_CMS_nn values in + * case of failure + */ +int cmsGetConfigParmExt(const CrossMemoryServerName *serverName, + const char *name, + void *valueBuffer, + int valueBufferSize, + CrossMemoryServerConfigParmExt *parm, + int *rsn); + + +/** + * @brief Get a parameter from the cross-memory server's PARMLIB without the + * authorization check (the caller must be SUP or system key) + * @param[in] serverName Cross-memory server whose parameter is to be read + * @param[in] name Name of the parameter + * @param[out] valueBuffer Buffer for the result value + * @param[out] valueBufferSize Size of the value buffer + * @param[out] parm Result parameter entry + * @param[out] rsn Reason code provided by the service in case of a failure + * @return RC_CMS_OK in case of success, and one of the RC_CMS_nn values in + * case of failure + */ +int cmsGetConfigParmExtUnchecked(const CrossMemoryServerName *serverName, + const char *name, + void *valueBuffer, + int valueBufferSize, + CrossMemoryServerConfigParmExt *parm, + int *rsn); int cmsGetPCLogLevel(const CrossMemoryServerName *serverName); CrossMemoryServerStatus cmsGetStatus(const CrossMemoryServerName *serverName); From a2dca1d565e44225c73536ece7ece3fb89d19020 Mon Sep 17 00:00:00 2001 From: Gautham Kuppuswamy Date: Tue, 27 Aug 2024 23:55:50 -0400 Subject: [PATCH 7/8] Adding an extra argument to httpClientSessionInit to return rc and changing api version Signed-off-by: Gautham Kuppuswamy --- CHANGELOG.md | 3 +++ c/httpclient.c | 16 +++++++++------- c/qjsnet.c | 3 ++- h/httpclient.h | 2 +- 4 files changed, 15 insertions(+), 9 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a0fe357cf..224e2bbec 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,8 @@ # Zowe Common C Changelog +## `2.19.0` +- Adding more arguments to httpClientSessionInit to allow passing back rc (#467). + ## `2.18.1` - Bugfix: IARV64 results must be checked for 0x7FFFF000 (#474) - Bugfix: SLH should not ABEND when MEMLIMIT is reached (additional NULL check) diff --git a/c/httpclient.c b/c/httpclient.c index 3d2c40f3c..172154897 100644 --- a/c/httpclient.c +++ b/c/httpclient.c @@ -647,12 +647,14 @@ void httpClientSessionDestroy(HttpClientSession *session) { /** * After this call, an stcbase'd caller should 'register' the socket */ -int httpClientSessionInit(HttpClientContext *ctx, HttpClientSession **outSession) { +int httpClientSessionInit2(HttpClientContext *ctx, HttpClientSession **outSession, int *rc) { int sts = 0; - int bpxrc = 0, bpxrsn = 0; + int bpxrsn = 0; + int *bpxrc = rc; HttpClientSession *session = NULL; ShortLivedHeap *slh = NULL; + *bpxrc = 0; do { if ((NULL == ctx) || (NULL == outSession)) { @@ -660,13 +662,13 @@ int httpClientSessionInit(HttpClientContext *ctx, HttpClientSession **outSession break; } - Socket *socket = tcpClient2(ctx->serverAddress, 1000 * ctx->recvTimeoutSeconds, &bpxrc, &bpxrsn); - if ((bpxrc != 0) || (NULL == socket)) { + Socket *socket = tcpClient2(ctx->serverAddress, 1000 * ctx->recvTimeoutSeconds, bpxrc, &bpxrsn); + if ((*bpxrc != 0) || (NULL == socket)) { #ifdef __ZOWE_OS_ZOS - HTTP_CLIENT_TRACE_VERBOSE("%s (rc=%d, rsn=0x%x, addr=0x%08x, port=%d)\n", HTTP_CLIENT_MSG_CONNECT_FAILED, bpxrc, + HTTP_CLIENT_TRACE_VERBOSE("%s (rc=%d, rsn=0x%x, addr=0x%08x, port=%d)\n", HTTP_CLIENT_MSG_CONNECT_FAILED, *bpxrc, bpxrsn, ctx->serverAddress->v4Address, ctx->serverAddress->port); #else - HTTP_CLIENT_TRACE_VERBOSE("%s (rc=%d, rsn=0x%x, addr=0x%08x, port=%d)\n", HTTP_CLIENT_MSG_CONNECT_FAILED, bpxrc, + HTTP_CLIENT_TRACE_VERBOSE("%s (rc=%d, rsn=0x%x, addr=0x%08x, port=%d)\n", HTTP_CLIENT_MSG_CONNECT_FAILED, *bpxrc, bpxrsn, ctx->serverAddress->internalAddress.v4Address, ctx->serverAddress->port); #endif sts = HTTP_CLIENT_CONNECT_FAILED; @@ -684,7 +686,7 @@ int httpClientSessionInit(HttpClientContext *ctx, HttpClientSession **outSession int rc = tlsSocketInit(ctx->tlsEnvironment, &socket->tlsSocket, socket->sd, false); if (rc != 0) { HTTP_CLIENT_TRACE_VERBOSE("failed to init tls socket, rc=%d, (%s)", rc, tlsStrError(rc)); - socketClose(socket, &bpxrc, &bpxrsn); + socketClose(socket, bpxrc, &bpxrsn); sts = HTTP_CLIENT_TLS_ERROR; break; } diff --git a/c/qjsnet.c b/c/qjsnet.c index ac2fcfbc0..3235801be 100644 --- a/c/qjsnet.c +++ b/c/qjsnet.c @@ -189,6 +189,7 @@ static int httpGet(bool isTLS, int status = 0; char buffer[2048]; LoggingContext *loggingContext = getLoggingContext(); + int rc = 0; do{ clientSettings.host = host; @@ -216,7 +217,7 @@ static int httpGet(bool isTLS, if (httpTrace){ printf("successfully initialized http client\n"); } - status = httpClientSessionInit(httpClientContext, &session); + status = httpClientSessionInit2(httpClientContext, &session, &rc); if (status){ if (httpTrace){ printf("error initing session: %d\n", status); diff --git a/h/httpclient.h b/h/httpclient.h index 937caa261..79ead6409 100644 --- a/h/httpclient.h +++ b/h/httpclient.h @@ -121,7 +121,7 @@ int httpClientContextInitSecure(HttpClientSettings *settings, void httpClientSessionDestroy(HttpClientSession *session); -int httpClientSessionInit(HttpClientContext *ctx, HttpClientSession **outSession); +int httpClientSessionInit2(HttpClientContext *ctx, HttpClientSession **outSession, int *rc); int httpClientSessionStageRequest(HttpClientContext *ctx, HttpClientSession *session, From 95b9973a5b9863a8452ec803a851472d44c12f10 Mon Sep 17 00:00:00 2001 From: JoeNemo Date: Wed, 4 Sep 2024 11:28:23 -0400 Subject: [PATCH 8/8] Revert "Returning internal return code through function argument for 'httpClientSessionInit'" --- CHANGELOG.md | 3 --- c/httpclient.c | 16 +++++++--------- c/qjsnet.c | 3 +-- h/httpclient.h | 2 +- 4 files changed, 9 insertions(+), 15 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 224e2bbec..a0fe357cf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,8 +1,5 @@ # Zowe Common C Changelog -## `2.19.0` -- Adding more arguments to httpClientSessionInit to allow passing back rc (#467). - ## `2.18.1` - Bugfix: IARV64 results must be checked for 0x7FFFF000 (#474) - Bugfix: SLH should not ABEND when MEMLIMIT is reached (additional NULL check) diff --git a/c/httpclient.c b/c/httpclient.c index 172154897..3d2c40f3c 100644 --- a/c/httpclient.c +++ b/c/httpclient.c @@ -647,14 +647,12 @@ void httpClientSessionDestroy(HttpClientSession *session) { /** * After this call, an stcbase'd caller should 'register' the socket */ -int httpClientSessionInit2(HttpClientContext *ctx, HttpClientSession **outSession, int *rc) { +int httpClientSessionInit(HttpClientContext *ctx, HttpClientSession **outSession) { int sts = 0; - int bpxrsn = 0; - int *bpxrc = rc; + int bpxrc = 0, bpxrsn = 0; HttpClientSession *session = NULL; ShortLivedHeap *slh = NULL; - *bpxrc = 0; do { if ((NULL == ctx) || (NULL == outSession)) { @@ -662,13 +660,13 @@ int httpClientSessionInit2(HttpClientContext *ctx, HttpClientSession **outSessio break; } - Socket *socket = tcpClient2(ctx->serverAddress, 1000 * ctx->recvTimeoutSeconds, bpxrc, &bpxrsn); - if ((*bpxrc != 0) || (NULL == socket)) { + Socket *socket = tcpClient2(ctx->serverAddress, 1000 * ctx->recvTimeoutSeconds, &bpxrc, &bpxrsn); + if ((bpxrc != 0) || (NULL == socket)) { #ifdef __ZOWE_OS_ZOS - HTTP_CLIENT_TRACE_VERBOSE("%s (rc=%d, rsn=0x%x, addr=0x%08x, port=%d)\n", HTTP_CLIENT_MSG_CONNECT_FAILED, *bpxrc, + HTTP_CLIENT_TRACE_VERBOSE("%s (rc=%d, rsn=0x%x, addr=0x%08x, port=%d)\n", HTTP_CLIENT_MSG_CONNECT_FAILED, bpxrc, bpxrsn, ctx->serverAddress->v4Address, ctx->serverAddress->port); #else - HTTP_CLIENT_TRACE_VERBOSE("%s (rc=%d, rsn=0x%x, addr=0x%08x, port=%d)\n", HTTP_CLIENT_MSG_CONNECT_FAILED, *bpxrc, + HTTP_CLIENT_TRACE_VERBOSE("%s (rc=%d, rsn=0x%x, addr=0x%08x, port=%d)\n", HTTP_CLIENT_MSG_CONNECT_FAILED, bpxrc, bpxrsn, ctx->serverAddress->internalAddress.v4Address, ctx->serverAddress->port); #endif sts = HTTP_CLIENT_CONNECT_FAILED; @@ -686,7 +684,7 @@ int httpClientSessionInit2(HttpClientContext *ctx, HttpClientSession **outSessio int rc = tlsSocketInit(ctx->tlsEnvironment, &socket->tlsSocket, socket->sd, false); if (rc != 0) { HTTP_CLIENT_TRACE_VERBOSE("failed to init tls socket, rc=%d, (%s)", rc, tlsStrError(rc)); - socketClose(socket, bpxrc, &bpxrsn); + socketClose(socket, &bpxrc, &bpxrsn); sts = HTTP_CLIENT_TLS_ERROR; break; } diff --git a/c/qjsnet.c b/c/qjsnet.c index 3235801be..ac2fcfbc0 100644 --- a/c/qjsnet.c +++ b/c/qjsnet.c @@ -189,7 +189,6 @@ static int httpGet(bool isTLS, int status = 0; char buffer[2048]; LoggingContext *loggingContext = getLoggingContext(); - int rc = 0; do{ clientSettings.host = host; @@ -217,7 +216,7 @@ static int httpGet(bool isTLS, if (httpTrace){ printf("successfully initialized http client\n"); } - status = httpClientSessionInit2(httpClientContext, &session, &rc); + status = httpClientSessionInit(httpClientContext, &session); if (status){ if (httpTrace){ printf("error initing session: %d\n", status); diff --git a/h/httpclient.h b/h/httpclient.h index 79ead6409..937caa261 100644 --- a/h/httpclient.h +++ b/h/httpclient.h @@ -121,7 +121,7 @@ int httpClientContextInitSecure(HttpClientSettings *settings, void httpClientSessionDestroy(HttpClientSession *session); -int httpClientSessionInit2(HttpClientContext *ctx, HttpClientSession **outSession, int *rc); +int httpClientSessionInit(HttpClientContext *ctx, HttpClientSession **outSession); int httpClientSessionStageRequest(HttpClientContext *ctx, HttpClientSession *session,