@@ -8055,25 +8055,27 @@ static int DoUserAuthInfoRequest(WOLFSSH* ssh, byte* buf, word32 len,
80558055 byte *language = NULL;
80568056 byte *echo = NULL;
80578057 byte **prompts = NULL;
8058+ void *heap = NULL;
80588059
80598060 WLOG(WS_LOG_DEBUG, "Entering DoUserAuthInfoRequest()");
80608061
80618062 if (ssh == NULL || buf == NULL || len == 0 || idx == NULL)
80628063 ret = WS_BAD_ARGUMENT;
80638064
8065+ if (ssh->ctx != NULL) {
8066+ heap = ssh->ctx->heap;
8067+ }
8068+
80648069 if (ret == WS_SUCCESS) {
80658070 begin = *idx;
8066- ret = GetStringAlloc(ssh->ctx->heap, (char**)&authName, buf, len,
8067- &begin);
8071+ ret = GetStringAlloc(heap, (char**)&authName, buf, len, &begin);
80688072 }
80698073
80708074 if (ret == WS_SUCCESS)
8071- ret = GetStringAlloc(ssh->ctx->heap, (char**)&authInstruction, buf, len,
8072- &begin);
8075+ ret = GetStringAlloc(heap, (char**)&authInstruction, buf, len, &begin);
80738076
80748077 if (ret == WS_SUCCESS)
8075- ret = GetStringAlloc(ssh->ctx->heap, (char**)&language, buf, len,
8076- &begin);
8078+ ret = GetStringAlloc(heap, (char**)&language, buf, len, &begin);
80778079
80788080 if (ret == WS_SUCCESS)
80798081 ret = GetUint32(&promptSz, buf, len, &begin);
@@ -8085,13 +8087,13 @@ static int DoUserAuthInfoRequest(WOLFSSH* ssh, byte* buf, word32 len,
80858087 }
80868088
80878089 if (ret == WS_SUCCESS && promptSz) {
8088- prompts = (byte**)WMALLOC(sizeof(byte*) * promptSz, ssh->ctx-> heap,
8090+ prompts = (byte**)WMALLOC(sizeof(byte*) * promptSz, heap,
80898091 DYNTYPE_BUFFER);
80908092 if (!prompts) {
80918093 ret = WS_MEMORY_E;
80928094 } else {
80938095 WMEMSET(prompts, '\0', sizeof(char*) * promptSz);
8094- echo = (byte*)WMALLOC(sizeof(byte) * promptSz, ssh->ctx-> heap,
8096+ echo = (byte*)WMALLOC(sizeof(byte) * promptSz, heap,
80958097 DYNTYPE_BUFFER);
80968098 }
80978099
@@ -8100,7 +8102,7 @@ static int DoUserAuthInfoRequest(WOLFSSH* ssh, byte* buf, word32 len,
81008102 } else {
81018103 WMEMSET(echo, 0, sizeof(byte) * promptSz);
81028104 for (entry = 0; entry < promptSz; entry++) {
8103- ret = GetStringAlloc(ssh->ctx-> heap, (char**)&prompts[entry],
8105+ ret = GetStringAlloc(heap, (char**)&prompts[entry],
81048106 buf, len, &begin);
81058107 if (ret != WS_SUCCESS)
81068108 break;
@@ -8123,16 +8125,16 @@ static int DoUserAuthInfoRequest(WOLFSSH* ssh, byte* buf, word32 len,
81238125 } else {
81248126 if (prompts) {
81258127 for (entry = 0; entry < promptSz; entry++) {
8126- WFREE((void*)prompts[entry], ssh->ctx-> heap, DYNTYPE_BUFFER);
8128+ WFREE((void*)prompts[entry], heap, DYNTYPE_BUFFER);
81278129 }
81288130 }
8129- WFREE(prompts, ssh->ctx-> heap, DYNTYPE_BUFFER);
8130- WFREE(echo, ssh->ctx-> heap, DYNTYPE_BUFFER);
8131+ WFREE(prompts, heap, DYNTYPE_BUFFER);
8132+ WFREE(echo, heap, DYNTYPE_BUFFER);
81318133
81328134 /* free strings in fail case */
8133- WFREE(authName, ssh->ctx-> heap, DYNTYPE_STRING);
8134- WFREE(authInstruction, ssh->ctx-> heap, DYNTYPE_STRING);
8135- WFREE(language, ssh->ctx-> heap, DYNTYPE_STRING);
8135+ WFREE(authName, heap, DYNTYPE_STRING);
8136+ WFREE(authInstruction, heap, DYNTYPE_STRING);
8137+ WFREE(language, heap, DYNTYPE_STRING);
81368138 }
81378139
81388140 if (ret == WS_SUCCESS) {
0 commit comments