Skip to content

Commit

Permalink
Clear password when session ends
Browse files Browse the repository at this point in the history
Any password stored in SCP_SESSION is now cleared before storage
is returned to the heap
  • Loading branch information
matt335672 committed Nov 28, 2022
1 parent 56a7c3e commit 4a8e5d3
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion sesman/libscp/libscp_session.c
Original file line number Diff line number Diff line change
Expand Up @@ -427,14 +427,29 @@ scp_session_set_guid(struct SCP_SESSION *s, const struct guid *guid)
return 0;
}

/*******************************************************************/
static void
clear_and_free_string(char *p)
{
if (p != NULL)
{
char *cp;
for (cp = p ; *cp != '\0'; ++cp)
{
*cp = '\0';
}
g_free(p);
}
}

/*******************************************************************/
void
scp_session_destroy(struct SCP_SESSION *s)
{
if (s != NULL)
{
g_free(s->username);
g_free(s->password);
clear_and_free_string(s->password);
g_free(s->hostname);
g_free(s->domain);
g_free(s->program);
Expand Down

0 comments on commit 4a8e5d3

Please sign in to comment.