Commit da03c8eb authored by LEFEBVREJP email's avatar LEFEBVREJP email
Browse files

Fixing double free of session.

parent 052b45f3
...@@ -35,6 +35,7 @@ class SessionWorkerImpl ...@@ -35,6 +35,7 @@ class SessionWorkerImpl
if (session != nullptr) if (session != nullptr)
{ {
ssh_free(session); ssh_free(session);
ssh_finalize();
} }
} }
}; };
...@@ -107,8 +108,6 @@ void SessionWorker::disconnect() ...@@ -107,8 +108,6 @@ void SessionWorker::disconnect()
{ {
radix_tagged_line("Disconnecting session."); radix_tagged_line("Disconnecting session.");
ssh_disconnect(p->session); ssh_disconnect(p->session);
ssh_free(p->session);
ssh_finalize();
} }
} }
...@@ -264,6 +263,7 @@ void SessionWorker::requestExec(QString command) ...@@ -264,6 +263,7 @@ void SessionWorker::requestExec(QString command)
{ {
assert_ssh_session(p->session, "request_exec() -- Session is not allocated."); assert_ssh_session(p->session, "request_exec() -- Session is not allocated.");
radix_tagged_line("requestExec(" << command.toStdString() << ")");
char buffer[256]; char buffer[256];
// clear any previous buffer // clear any previous buffer
p->output_buffer.clear(); p->output_buffer.clear();
...@@ -294,10 +294,10 @@ void SessionWorker::requestExec(QString command) ...@@ -294,10 +294,10 @@ void SessionWorker::requestExec(QString command)
{ {
p->output_buffer.append(buffer, nbytes); p->output_buffer.append(buffer, nbytes);
emit execOutputReady(); emit execOutputReady();
radix(nbytes);
nbytes = ssh_channel_read(channel, buffer, sizeof(buffer), 0); nbytes = ssh_channel_read(channel, buffer, sizeof(buffer), 0);
} }
radix_tagged_line(); radix_tagged_line("nbytes=" << nbytes);
radix_tagged_line("Finished reading response\n" << p->output_buffer.data());
if (nbytes == 0) if (nbytes == 0)
{ {
......
...@@ -5,13 +5,14 @@ ...@@ -5,13 +5,14 @@
using namespace rsm; using namespace rsm;
TEST(RSM, Session) TEST(RSM, Session)
{ {
SessionWorker session("warroom4"); SessionWorker session("nfecc");
session.setLogVerbosity(SessionWorker::Verbosity::Functions); session.setLogVerbosity(SessionWorker::Verbosity::None);
session.setPort(22); session.setPort(22);
session.setUser("jap"); session.setUser("jap");
session.connect(); // 1) hand-shake with host session.connect(); // 1) hand-shake with host
session.verifyKnownHost(); // 2) verify host is known/acceptable session.verifyKnownHost(); // 2) verify host is known/acceptable
session.authenticate(); // 3) process authentication session.authenticate(); // 3) process authentication
session.requestExec("ls -la"); session.requestExec("ls -la");
session.requestExec("ls modulefiles");
session.disconnect(); session.disconnect();
} }
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment