Skip to content

Commit 97c3faf

Browse files
initialize array and free dynamic strings on failure
1 parent 179df42 commit 97c3faf

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/internal.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7886,14 +7886,15 @@ static int DoUserAuthInfoRequest(WOLFSSH* ssh, byte* buf, word32 len,
78867886
if (!prompts) {
78877887
ret = WS_MEMORY_E;
78887888
} else {
7889+
WMEMSET(prompts, '\0', sizeof(char*) * promptSz);
78897890
echo = (byte*)WMALLOC(sizeof(byte) * promptSz, ssh->ctx->heap,
78907891
DYNTYPE_BUFFER);
78917892
}
78927893

78937894
if (!echo) {
78947895
ret = WS_MEMORY_E;
78957896
} else {
7896-
WMEMSET(prompts, '\0', sizeof(char*) * promptSz);
7897+
WMEMSET(echo, 0, sizeof(byte) * promptSz);
78977898
for (entry = 0; entry < promptSz; entry++) {
78987899
ret = GetStringAlloc(ssh->ctx->heap, (char**)&prompts[entry],
78997900
buf, len, &begin);
@@ -7923,6 +7924,11 @@ static int DoUserAuthInfoRequest(WOLFSSH* ssh, byte* buf, word32 len,
79237924
}
79247925
WFREE(prompts, ssh->ctx->heap, DYNTYPE_BUFFER);
79257926
WFREE(echo, ssh->ctx->heap, DYNTYPE_BUFFER);
7927+
7928+
/* free strings in fail case */
7929+
WFREE(authName, ssh->ctx->heap, DYNTYPE_STRING);
7930+
WFREE(authInstruction, ssh->ctx->heap, DYNTYPE_STRING);
7931+
WFREE(language, ssh->ctx->heap, DYNTYPE_STRING);
79267932
}
79277933

79287934
if (ret == WS_SUCCESS)

0 commit comments

Comments
 (0)