From 8aa2bbd0dc265f18dcc209e41aac5cfdf56bf568 Mon Sep 17 00:00:00 2001 From: Andreas Schneider Date: Mon, 28 Oct 2019 14:29:44 +0100 Subject: [PATCH] SSH-01-006: Add missing NULL check in ssh_scp_push_directory() Fixes T193 Signed-off-by: Andreas Schneider Reviewed-by: Jakub Jelen --- src/scp.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/scp.c b/src/scp.c index c94d5c09..6a78717d 100644 --- a/src/scp.c +++ b/src/scp.c @@ -335,7 +335,18 @@ int ssh_scp_push_directory(ssh_scp scp, const char *dirname, int mode) } dir = ssh_basename(dirname); + if (dir == NULL) { + ssh_set_error_oom(scp->session); + return SSH_ERROR; + } + perms = ssh_scp_string_mode(mode); + if (perms == NULL) { + SAFE_FREE(dir); + ssh_set_error_oom(scp->session); + return SSH_ERROR; + } + snprintf(buffer, sizeof(buffer), "D%s 0 %s\n", perms, dir); SAFE_FREE(dir); SAFE_FREE(perms);