Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
LEFEBVREJP email
rsm
Commits
da03c8eb
Commit
da03c8eb
authored
Jan 17, 2020
by
LEFEBVREJP email
Browse files
Fixing double free of session.
parent
052b45f3
Changes
2
Hide whitespace changes
Inline
Side-by-side
rsmcore/sessionworker.cc
View file @
da03c8eb
...
@@ -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
)
{
{
...
...
rsmcore/tests/tstSession.cc
View file @
da03c8eb
...
@@ -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
::
Functi
on
s
);
session
.
setLogVerbosity
(
SessionWorker
::
Verbosity
::
N
on
e
);
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
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment