From c93a730bc1f3cfb78dbc74a78dc6f2ef6d5e51dd Mon Sep 17 00:00:00 2001 From: Jakub Jelen Date: Fri, 31 May 2024 09:15:05 +0200 Subject: [PATCH] examples: Make sure the callback structure is initialized When the callback structure is allocated with malloc, some fields might be uninitialized and therefore could cause undefined behavior or crashes. Signed-off-by: Jakub Jelen Reviewed-by: Sahana Prasad --- examples/sshd_direct-tcpip.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/sshd_direct-tcpip.c b/examples/sshd_direct-tcpip.c index 84389b28..744c5aa6 100644 --- a/examples/sshd_direct-tcpip.c +++ b/examples/sshd_direct-tcpip.c @@ -526,7 +526,7 @@ message_callback(UNUSED_PARAM(ssh_session session), } pFd = malloc(sizeof *pFd); - cb_chan = malloc(sizeof *cb_chan); + cb_chan = calloc(1, sizeof *cb_chan); event_fd_data = malloc(sizeof *event_fd_data); if (pFd == NULL || cb_chan == NULL || event_fd_data == NULL) { SAFE_FREE(pFd);