Skip to content

Commit c5c52ee

Browse files
Fix memory management in serverKeyboardCallback for empty prompts
Co-Authored-By: andrew@wolfssl.com <andrew@wolfssl.com>
1 parent 63db9f1 commit c5c52ee

1 file changed

Lines changed: 11 additions & 1 deletion

File tree

tests/auth.c

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,17 @@ static int serverUserAuth(byte authType, WS_UserAuthData* authData, void* ctx)
280280
static int serverKeyboardCallback(WS_UserAuthData_Keyboard *kbAuth, void *ctx)
281281
{
282282
(void) ctx;
283-
WMEMCPY(kbAuth, &promptData, sizeof(WS_UserAuthData_Keyboard));
283+
/* Copy individual fields instead of the entire structure to avoid memory issues */
284+
kbAuth->promptCount = promptData.promptCount;
285+
kbAuth->promptName = promptData.promptName;
286+
kbAuth->promptNameSz = promptData.promptNameSz;
287+
kbAuth->promptInstruction = promptData.promptInstruction;
288+
kbAuth->promptInstructionSz = promptData.promptInstructionSz;
289+
kbAuth->promptLanguage = promptData.promptLanguage;
290+
kbAuth->promptLanguageSz = promptData.promptLanguageSz;
291+
kbAuth->prompts = promptData.prompts;
292+
kbAuth->promptLengths = promptData.promptLengths;
293+
kbAuth->promptEcho = promptData.promptEcho;
284294

285295
return WS_SUCCESS;
286296
}

0 commit comments

Comments
 (0)