Skip to content

Commit

Permalink
Fix Modes Leak
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
ejohnstown committed Mar 14, 2024
1 parent c07a868 commit e6ffad0
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/internal.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
}


Expand Down Expand Up @@ -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;
}
Expand Down

0 comments on commit e6ffad0

Please sign in to comment.