mirror of
https://git.libssh.org/projects/libssh.git
synced 2026-01-06 14:21:55 +03:00
tests: Remove needless assignemnt and clean memory on errors
Signed-off-by: Jakub Jelen <jjelen@redhat.com> Reviewed-by: Andreas Schneider <asn@cryptomilk.org> Reviewed-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
This commit is contained in:
@@ -886,7 +886,6 @@ void default_handle_session_cb(ssh_event event,
|
||||
}
|
||||
|
||||
sdata.server_state = (void *)state;
|
||||
cdata.server_state = (void *)state;
|
||||
|
||||
#ifdef WITH_PCAP
|
||||
set_pcap(&sdata, session, state->pcap_file);
|
||||
@@ -902,7 +901,7 @@ void default_handle_session_cb(ssh_event event,
|
||||
|
||||
if (ssh_handle_key_exchange(session) != SSH_OK) {
|
||||
fprintf(stderr, "%s\n", ssh_get_error(session));
|
||||
return;
|
||||
goto end;
|
||||
}
|
||||
|
||||
/* Set the supported authentication methods */
|
||||
@@ -921,7 +920,7 @@ void default_handle_session_cb(ssh_event event,
|
||||
/* If the user has used up all attempts, or if he hasn't been able to
|
||||
* authenticate in 10 seconds (n * 100ms), disconnect. */
|
||||
if (sdata.auth_attempts >= state->max_tries || n >= 100) {
|
||||
return;
|
||||
goto end;
|
||||
}
|
||||
|
||||
if (ssh_event_dopoll(event, 100) == SSH_ERROR) {
|
||||
|
||||
@@ -190,7 +190,7 @@ static void cleanup_pcap(struct session_data_st *sdata)
|
||||
|
||||
/* The caller is responsible to set the userdata to be provided to the callback
|
||||
* The caller is responsible to free the allocated structure
|
||||
* */
|
||||
*/
|
||||
struct ssh_server_callbacks_struct *get_sftp_server_cb(void)
|
||||
{
|
||||
|
||||
@@ -313,7 +313,7 @@ void sftp_handle_session_cb(ssh_event event,
|
||||
|
||||
if (ssh_handle_key_exchange(session) != SSH_OK) {
|
||||
fprintf(stderr, "%s\n", ssh_get_error(session));
|
||||
return;
|
||||
goto end;
|
||||
}
|
||||
|
||||
/* Set the supported authentication methods */
|
||||
@@ -332,12 +332,12 @@ void sftp_handle_session_cb(ssh_event event,
|
||||
/* If the user has used up all attempts, or if he hasn't been able to
|
||||
* authenticate in 10 seconds (n * 100ms), disconnect. */
|
||||
if (sdata.auth_attempts >= state->max_tries || n >= 100) {
|
||||
return;
|
||||
goto end;
|
||||
}
|
||||
|
||||
if (ssh_event_dopoll(event, 100) == SSH_ERROR) {
|
||||
fprintf(stderr, "do_poll error: %s\n", ssh_get_error(session));
|
||||
return;
|
||||
goto end;
|
||||
}
|
||||
n++;
|
||||
}
|
||||
@@ -382,6 +382,7 @@ void sftp_handle_session_cb(ssh_event event,
|
||||
|
||||
ssh_channel_send_eof(sdata.channel);
|
||||
ssh_channel_close(sdata.channel);
|
||||
sftp_server_free(cdata.sftp);
|
||||
|
||||
/* Wait up to 5 seconds for the client to terminate the session. */
|
||||
for (n = 0; n < 50 && (ssh_get_status(session) & SESSION_END) == 0; n++) {
|
||||
|
||||
Reference in New Issue
Block a user