Fix memory leak: free session data
Call scp_session_destroy() in the functions that call scp_session_create() and nowhere else. As found by Valgrind, the session data is not freed if the session is created successfully.
This commit is contained in:
parent
8bf28e45c4
commit
65ac8e758b
@ -330,7 +330,6 @@ scp_v1s_request_password(struct SCP_CONNECTION *c, struct SCP_SESSION *s,
|
||||
|
||||
if (0 != scp_session_set_username(s, buf))
|
||||
{
|
||||
scp_session_destroy(s);
|
||||
log_message(LOG_LEVEL_WARNING, "[v1s:%d] connection aborted: internal error", __LINE__);
|
||||
return SCP_SERVER_STATE_INTERNAL_ERR;
|
||||
}
|
||||
@ -342,7 +341,6 @@ scp_v1s_request_password(struct SCP_CONNECTION *c, struct SCP_SESSION *s,
|
||||
|
||||
if (0 != scp_session_set_password(s, buf))
|
||||
{
|
||||
scp_session_destroy(s);
|
||||
log_message(LOG_LEVEL_WARNING, "[v1s:%d] connection aborted: internal error", __LINE__);
|
||||
return SCP_SERVER_STATE_INTERNAL_ERR;
|
||||
}
|
||||
|
@ -36,7 +36,7 @@ void *DEFAULT_CC
|
||||
scp_process_start(void *sck)
|
||||
{
|
||||
struct SCP_CONNECTION scon;
|
||||
struct SCP_SESSION *sdata;
|
||||
struct SCP_SESSION *sdata = NULL;
|
||||
|
||||
scon.in_sck = (int)(tintptr)sck;
|
||||
LOG_DBG("started scp thread on socket %d", scon.in_sck);
|
||||
@ -89,9 +89,16 @@ scp_process_start(void *sck)
|
||||
break;
|
||||
default:
|
||||
log_message(LOG_LEVEL_ALWAYS, "unknown return from scp_vXs_accept()");
|
||||
break;
|
||||
}
|
||||
|
||||
free_stream(scon.in_s);
|
||||
free_stream(scon.out_s);
|
||||
|
||||
if (sdata)
|
||||
{
|
||||
scp_session_destroy(sdata);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -77,7 +77,6 @@ scp_v1_process(struct SCP_CONNECTION *c, struct SCP_SESSION *s)
|
||||
default:
|
||||
/* we check the other errors */
|
||||
parseCommonStates(e, "scp_v1s_list_sessions()");
|
||||
scp_session_destroy(s);
|
||||
return;
|
||||
//break;
|
||||
}
|
||||
@ -88,7 +87,6 @@ scp_v1_process(struct SCP_CONNECTION *c, struct SCP_SESSION *s)
|
||||
scp_v1s_deny_connection(c, "Login failed");
|
||||
log_message( LOG_LEVEL_INFO,
|
||||
"Login failed for user %s. Connection terminated", s->username);
|
||||
scp_session_destroy(s);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -98,7 +96,6 @@ scp_v1_process(struct SCP_CONNECTION *c, struct SCP_SESSION *s)
|
||||
scp_v1s_deny_connection(c, "Access to Terminal Server not allowed.");
|
||||
log_message(LOG_LEVEL_INFO,
|
||||
"User %s not allowed on TS. Connection terminated", s->username);
|
||||
scp_session_destroy(s);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -204,7 +201,6 @@ scp_v1_process(struct SCP_CONNECTION *c, struct SCP_SESSION *s)
|
||||
}
|
||||
|
||||
/* cleanup */
|
||||
scp_session_destroy(s);
|
||||
auth_end(data);
|
||||
g_free(slist);
|
||||
}
|
||||
|
@ -50,7 +50,6 @@ scp_v1_mng_process(struct SCP_CONNECTION *c, struct SCP_SESSION *s)
|
||||
scp_v1s_mng_deny_connection(c, "Login failed");
|
||||
log_message(LOG_LEVEL_INFO,
|
||||
"[MNG] Login failed for user %s. Connection terminated", s->username);
|
||||
scp_session_destroy(s);
|
||||
auth_end(data);
|
||||
return;
|
||||
}
|
||||
@ -61,7 +60,6 @@ scp_v1_mng_process(struct SCP_CONNECTION *c, struct SCP_SESSION *s)
|
||||
scp_v1s_mng_deny_connection(c, "Access to Terminal Server not allowed.");
|
||||
log_message(LOG_LEVEL_INFO,
|
||||
"[MNG] User %s not allowed on TS. Connection terminated", s->username);
|
||||
scp_session_destroy(s);
|
||||
auth_end(data);
|
||||
return;
|
||||
}
|
||||
@ -105,7 +103,6 @@ scp_v1_mng_process(struct SCP_CONNECTION *c, struct SCP_SESSION *s)
|
||||
}
|
||||
|
||||
/* cleanup */
|
||||
scp_session_destroy(s);
|
||||
auth_end(data);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user