mirror of
https://github.com/libssh2/libssh2.git
synced 2026-10-24 03:48:58 +03:00
packet: fix memleak on receiving multiple exit-signal packets
Reported-by: afldl on github
Fixes GHSA-53q9-wmqr-fh7c
Follow-up to 6140ec2de3
Closes #2504
This commit is contained in:
@@ -1136,9 +1136,10 @@ ssh2_packet_add_jump_point1:
|
||||
rc = ssh2_err(session, LIBSSH2_ERROR_PROTO,
|
||||
"signal name out of bounds");
|
||||
else if(sig_len > 0) {
|
||||
if(channelp->exit_signal)
|
||||
SSH2_FREE(session, channelp->exit_signal);
|
||||
channelp->exit_signal =
|
||||
SSH2_ALLOC(session, sig_len + 1);
|
||||
|
||||
if(channelp->exit_signal) {
|
||||
memcpy(channelp->exit_signal,
|
||||
sig_name, sig_len);
|
||||
@@ -1155,8 +1156,8 @@ ssh2_packet_add_jump_point1:
|
||||
rc = ssh2_err(session, LIBSSH2_ERROR_ALLOC,
|
||||
"exit signal alloc error");
|
||||
}
|
||||
else
|
||||
channelp->exit_signal = NULL;
|
||||
else if(channelp->exit_signal)
|
||||
SSH2_SAFEFREE(session, channelp->exit_signal);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user