mirror of
https://git.libssh.org/projects/libssh.git
synced 2026-02-07 10:40:28 +09:00
refactor: wrap and move server session options in a new struct
Signed-off-by: Francesco Rollo <eferollo@gmail.com> Reviewed-by: Jakub Jelen <jjelen@redhat.com> Reviewed-by: Sahana Prasad <sahana@redhat.com>
This commit is contained in:
committed by
Sahana Prasad
parent
6c59d975ba
commit
b4ed60024b
@@ -480,16 +480,16 @@ int ssh_bind_accept_fd(ssh_bind sshbind, ssh_session session, socket_t fd)
|
||||
session->common.log_verbosity = sshbind->common.log_verbosity;
|
||||
|
||||
if (sshbind->banner != NULL) {
|
||||
session->opts.custombanner = strdup(sshbind->banner);
|
||||
if (session->opts.custombanner == NULL) {
|
||||
session->server_opts.custombanner = strdup(sshbind->banner);
|
||||
if (session->server_opts.custombanner == NULL) {
|
||||
ssh_set_error_oom(sshbind);
|
||||
return SSH_ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
if (sshbind->moduli_file != NULL) {
|
||||
session->opts.moduli_file = strdup(sshbind->moduli_file);
|
||||
if (session->opts.moduli_file == NULL) {
|
||||
session->server_opts.moduli_file = strdup(sshbind->moduli_file);
|
||||
if (session->server_opts.moduli_file == NULL) {
|
||||
ssh_set_error_oom(sshbind);
|
||||
return SSH_ERROR;
|
||||
}
|
||||
|
||||
@@ -185,13 +185,13 @@ int ssh_send_banner(ssh_session session, int server)
|
||||
int rc = SSH_ERROR;
|
||||
|
||||
if (server == 1) {
|
||||
if (session->opts.custombanner == NULL){
|
||||
if (session->server_opts.custombanner == NULL) {
|
||||
session->serverbanner = strdup(banner);
|
||||
if (session->serverbanner == NULL) {
|
||||
goto end;
|
||||
}
|
||||
} else {
|
||||
len = strlen(session->opts.custombanner);
|
||||
len = strlen(session->server_opts.custombanner);
|
||||
session->serverbanner = malloc(len + 8 + 1);
|
||||
if(session->serverbanner == NULL) {
|
||||
goto end;
|
||||
@@ -199,7 +199,7 @@ int ssh_send_banner(ssh_session session, int server)
|
||||
snprintf(session->serverbanner,
|
||||
len + 8 + 1,
|
||||
"SSH-2.0-%s",
|
||||
session->opts.custombanner);
|
||||
session->server_opts.custombanner);
|
||||
}
|
||||
|
||||
snprintf(buffer,
|
||||
|
||||
@@ -643,7 +643,7 @@ static SSH_PACKET_CALLBACK(ssh_packet_server_dhgex_request)
|
||||
pn = pmin;
|
||||
}
|
||||
}
|
||||
rc = ssh_retrieve_dhgroup(session->opts.moduli_file,
|
||||
rc = ssh_retrieve_dhgroup(session->server_opts.moduli_file,
|
||||
pmin,
|
||||
pn,
|
||||
pmax,
|
||||
|
||||
@@ -339,8 +339,6 @@ void ssh_free(ssh_session session)
|
||||
|
||||
SAFE_FREE(session->opts.agent_socket);
|
||||
SAFE_FREE(session->opts.bindaddr);
|
||||
SAFE_FREE(session->opts.custombanner);
|
||||
SAFE_FREE(session->opts.moduli_file);
|
||||
SAFE_FREE(session->opts.username);
|
||||
SAFE_FREE(session->opts.host);
|
||||
SAFE_FREE(session->opts.sshdir);
|
||||
@@ -358,6 +356,9 @@ void ssh_free(ssh_session session)
|
||||
}
|
||||
}
|
||||
|
||||
SAFE_FREE(session->server_opts.custombanner);
|
||||
SAFE_FREE(session->server_opts.moduli_file);
|
||||
|
||||
_ssh_remove_legacy_log_cb();
|
||||
|
||||
/* burn connection, it could contain sensitive data */
|
||||
|
||||
Reference in New Issue
Block a user