log: fixes legacy fallback for multiple sessions.

Legacy code in 'ssh_set_callbacks' will fallback to
'ssh_legacy_log_callback' (if the current log cb is
NULL) setting the user data to the current session.

However, if any other session is created afterwards,
it won't update the user data with the new session,
potentially leading to a use-after-free.

Fixes #238.

Signed-off-by: Diego Roux <diegoroux04@protonmail.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
This commit is contained in:
Diego Roux
2024-03-27 14:31:11 +00:00
committed by Jakub Jelen
parent 3227a4cae0
commit 46a28cfc49
6 changed files with 108 additions and 10 deletions

View File

@@ -274,6 +274,10 @@ void ssh_log_common(struct ssh_common_struct *common,
const char *function,
const char *format, ...) PRINTF_ATTRIBUTE(4, 5);
void _ssh_remove_legacy_log_cb(void);
/* log.c */
void _ssh_reset_log_cb(void);
/* ERROR HANDLING */