Fix Modes Leak

1. Add dynamic memory type of string to the allocation of the list of
   modes when opening a pty.
2. When freeing a WOLFSSH object, free modes when it is set.
pull/668/head
John Safranek 2024-03-14 09:47:27 -07:00
parent c07a86856e
commit e6ffad047d
No known key found for this signature in database
GPG Key ID: 8CE817DE0D3CCB4A
1 changed files with 8 additions and 1 deletions

View File

@ -1017,6 +1017,12 @@ void SshResourceFree(WOLFSSH* ssh, void* heap)
ssh->sftpDefaultPath = NULL;
}
#endif
#ifdef WOLFSSH_TERM
if (ssh->modes) {
WFREE(ssh->modes, ssh->ctx->heap, DYNTYPE_STRING);
ssh->modesSz = 0;
}
#endif
}
@ -7584,7 +7590,8 @@ static int DoChannelRequest(WOLFSSH* ssh,
if (ret == WS_SUCCESS)
ret = GetStringRef(&modesSz, &modes, buf, len, &begin);
if (ret == WS_SUCCESS) {
ssh->modes = (byte*)WMALLOC(modesSz, ssh->ctx->heap, 0);
ssh->modes = (byte*)WMALLOC(modesSz,
ssh->ctx->heap, DYNTYPE_STRING);
if (ssh->modes == NULL)
ret = WS_MEMORY_E;
}