mirror of
https://git.libssh.org/projects/libssh.git
synced 2025-11-29 01:03:57 +03:00
messages: Do not leak memory of previously allocated answers
Found by ozz-fuzz BUG: https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=1222 Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
This commit is contained in:
@@ -969,6 +969,15 @@ SSH_PACKET_CALLBACK(ssh_packet_userauth_info_response){
|
||||
|
||||
goto error;
|
||||
}
|
||||
} else if (session->kbdint->nanswers > 0) {
|
||||
uint32_t n;
|
||||
|
||||
for (n = 0; n < session->kbdint->nanswers; n++) {
|
||||
BURN_STRING(session->kbdint->answers[n]);
|
||||
SAFE_FREE(session->kbdint->answers[n]);
|
||||
}
|
||||
SAFE_FREE(session->kbdint->answers);
|
||||
session->kbdint->nanswers = 0;
|
||||
}
|
||||
|
||||
SSH_LOG(SSH_LOG_PACKET,"kbdint: %d answers",nanswers);
|
||||
@@ -989,7 +998,6 @@ SSH_PACKET_CALLBACK(ssh_packet_userauth_info_response){
|
||||
}
|
||||
session->kbdint->nanswers = nanswers;
|
||||
|
||||
SAFE_FREE(session->kbdint->answers);
|
||||
session->kbdint->answers = calloc(1, nanswers * sizeof(char *));
|
||||
if (session->kbdint->answers == NULL) {
|
||||
session->kbdint->nanswers = 0;
|
||||
@@ -1010,7 +1018,6 @@ SSH_PACKET_CALLBACK(ssh_packet_userauth_info_response){
|
||||
|
||||
goto error;
|
||||
}
|
||||
SAFE_FREE(session->kbdint->answers[i]);
|
||||
session->kbdint->answers[i] = ssh_string_to_char(tmp);
|
||||
ssh_string_free(tmp);
|
||||
if (session->kbdint->answers[i] == NULL) {
|
||||
|
||||
Reference in New Issue
Block a user