|
|
096905 |
From 3893140b1ff88d70407d5ab902022ab36d7305d7 Mon Sep 17 00:00:00 2001
|
|
|
096905 |
From: Marc Hoersken <info@marc-hoersken.de>
|
|
|
096905 |
Date: Mon, 23 Mar 2015 22:47:46 +0100
|
|
|
096905 |
Subject: [PATCH 1/5] scp.c: fix that scp_send may transmit not initialised
|
|
|
096905 |
memory
|
|
|
096905 |
|
|
|
096905 |
Fixes ticket 244. Thanks Torsten.
|
|
|
096905 |
|
|
|
096905 |
Upstream-commit: b99204f2896b0cdafa3ecc0736f0252ce44c32c7
|
|
|
096905 |
Signed-off-by: Kamil Dudka <kdudka@redhat.com>
|
|
|
096905 |
---
|
|
|
096905 |
src/scp.c | 6 ++++++
|
|
|
096905 |
1 file changed, 6 insertions(+)
|
|
|
096905 |
|
|
|
096905 |
diff --git a/src/scp.c b/src/scp.c
|
|
|
096905 |
index 63d181e..2f92804 100644
|
|
|
096905 |
--- a/src/scp.c
|
|
|
096905 |
+++ b/src/scp.c
|
|
|
096905 |
@@ -801,12 +801,18 @@ scp_send(LIBSSH2_SESSION * session, const char *path, int mode,
|
|
|
096905 |
|
|
|
096905 |
cmd_len = strlen((char *)session->scpSend_command);
|
|
|
096905 |
|
|
|
096905 |
+ memset(&session->scpSend_command[cmd_len], 0,
|
|
|
096905 |
+ session->scpSend_command_len - cmd_len);
|
|
|
096905 |
+
|
|
|
096905 |
(void)shell_quotearg(path,
|
|
|
096905 |
&session->scpSend_command[cmd_len],
|
|
|
096905 |
session->scpSend_command_len - cmd_len);
|
|
|
096905 |
|
|
|
096905 |
session->scpSend_command[session->scpSend_command_len - 1] = '\0';
|
|
|
096905 |
|
|
|
096905 |
+ session->scpSend_command_len =
|
|
|
096905 |
+ strlen((char *)session->scpSend_command);
|
|
|
096905 |
+
|
|
|
096905 |
_libssh2_debug(session, LIBSSH2_TRACE_SCP,
|
|
|
096905 |
"Opening channel for SCP send");
|
|
|
096905 |
/* Allocate a channel */
|
|
|
096905 |
--
|
|
|
096905 |
2.13.5
|
|
|
096905 |
|
|
|
096905 |
|
|
|
096905 |
From 2ecb8c5d6e116fcc71a31360115c9c2b4b0ca1d2 Mon Sep 17 00:00:00 2001
|
|
|
096905 |
From: Marc Hoersken <info@marc-hoersken.de>
|
|
|
096905 |
Date: Mon, 23 Mar 2015 23:04:24 +0100
|
|
|
096905 |
Subject: [PATCH 2/5] scp.c: fix that scp_recv may transmit not initialised
|
|
|
096905 |
memory
|
|
|
096905 |
|
|
|
096905 |
Upstream-commit: 1e7988cb0d8dae32148b04dd93e919a770599f30
|
|
|
096905 |
Signed-off-by: Kamil Dudka <kdudka@redhat.com>
|
|
|
096905 |
---
|
|
|
096905 |
src/scp.c | 7 +++++++
|
|
|
096905 |
1 file changed, 7 insertions(+)
|
|
|
096905 |
|
|
|
096905 |
diff --git a/src/scp.c b/src/scp.c
|
|
|
096905 |
index 2f92804..d0c0d26 100644
|
|
|
096905 |
--- a/src/scp.c
|
|
|
096905 |
+++ b/src/scp.c
|
|
|
096905 |
@@ -299,10 +299,17 @@ scp_recv(LIBSSH2_SESSION * session, const char *path, struct stat * sb)
|
|
|
096905 |
|
|
|
096905 |
cmd_len = strlen((char *)session->scpRecv_command);
|
|
|
096905 |
|
|
|
096905 |
+ memset(&session->scpRecv_command[cmd_len], 0,
|
|
|
096905 |
+ session->scpRecv_command_len - cmd_len);
|
|
|
096905 |
+
|
|
|
096905 |
(void) shell_quotearg(path,
|
|
|
096905 |
&session->scpRecv_command[cmd_len],
|
|
|
096905 |
session->scpRecv_command_len - cmd_len);
|
|
|
096905 |
|
|
|
096905 |
+ session->scpRecv_command[session->scpRecv_command_len - 1] = '\0';
|
|
|
096905 |
+
|
|
|
096905 |
+ session->scpRecv_command_len =
|
|
|
096905 |
+ strlen((char *)session->scpRecv_command);
|
|
|
096905 |
|
|
|
096905 |
_libssh2_debug(session, LIBSSH2_TRACE_SCP,
|
|
|
096905 |
"Opening channel for SCP receive");
|
|
|
096905 |
--
|
|
|
096905 |
2.13.5
|
|
|
096905 |
|
|
|
096905 |
|
|
|
096905 |
From 5b23e9e9875302791f5c190cf0e4f61fd9879ff0 Mon Sep 17 00:00:00 2001
|
|
|
096905 |
From: Marc Hoersken <info@marc-hoersken.de>
|
|
|
096905 |
Date: Mon, 23 Mar 2015 23:05:41 +0100
|
|
|
096905 |
Subject: [PATCH 3/5] scp.c: improved and streamlined formatting
|
|
|
096905 |
|
|
|
096905 |
Upstream-commit: 2d59b41daa3925645a26e6406fc318e6c2bfaae6
|
|
|
096905 |
Signed-off-by: Kamil Dudka <kdudka@redhat.com>
|
|
|
096905 |
---
|
|
|
096905 |
src/scp.c | 16 ++++++++++------
|
|
|
096905 |
1 file changed, 10 insertions(+), 6 deletions(-)
|
|
|
096905 |
|
|
|
096905 |
diff --git a/src/scp.c b/src/scp.c
|
|
|
096905 |
index d0c0d26..30d46af 100644
|
|
|
096905 |
--- a/src/scp.c
|
|
|
096905 |
+++ b/src/scp.c
|
|
|
096905 |
@@ -295,16 +295,17 @@ scp_recv(LIBSSH2_SESSION * session, const char *path, struct stat * sb)
|
|
|
096905 |
}
|
|
|
096905 |
|
|
|
096905 |
snprintf((char *)session->scpRecv_command,
|
|
|
096905 |
- session->scpRecv_command_len, "scp -%sf ", sb?"p":"");
|
|
|
096905 |
+ session->scpRecv_command_len,
|
|
|
096905 |
+ "scp -%sf ", sb?"p":"");
|
|
|
096905 |
|
|
|
096905 |
cmd_len = strlen((char *)session->scpRecv_command);
|
|
|
096905 |
|
|
|
096905 |
memset(&session->scpRecv_command[cmd_len], 0,
|
|
|
096905 |
session->scpRecv_command_len - cmd_len);
|
|
|
096905 |
|
|
|
096905 |
- (void) shell_quotearg(path,
|
|
|
096905 |
- &session->scpRecv_command[cmd_len],
|
|
|
096905 |
- session->scpRecv_command_len - cmd_len);
|
|
|
096905 |
+ (void)shell_quotearg(path,
|
|
|
096905 |
+ &session->scpRecv_command[cmd_len],
|
|
|
096905 |
+ session->scpRecv_command_len - cmd_len);
|
|
|
096905 |
|
|
|
096905 |
session->scpRecv_command[session->scpRecv_command_len - 1] = '\0';
|
|
|
096905 |
|
|
|
096905 |
@@ -797,13 +798,16 @@ scp_send(LIBSSH2_SESSION * session, const char *path, int mode,
|
|
|
096905 |
|
|
|
096905 |
session->scpSend_command =
|
|
|
096905 |
LIBSSH2_ALLOC(session, session->scpSend_command_len);
|
|
|
096905 |
+
|
|
|
096905 |
if (!session->scpSend_command) {
|
|
|
096905 |
_libssh2_error(session, LIBSSH2_ERROR_ALLOC,
|
|
|
096905 |
- "Unable to allocate a command buffer for scp session");
|
|
|
096905 |
+ "Unable to allocate a command buffer for "
|
|
|
096905 |
+ "SCP session");
|
|
|
096905 |
return NULL;
|
|
|
096905 |
}
|
|
|
096905 |
|
|
|
096905 |
- snprintf((char *)session->scpSend_command, session->scpSend_command_len,
|
|
|
096905 |
+ snprintf((char *)session->scpSend_command,
|
|
|
096905 |
+ session->scpSend_command_len,
|
|
|
096905 |
"scp -%st ", (mtime || atime)?"p":"");
|
|
|
096905 |
|
|
|
096905 |
cmd_len = strlen((char *)session->scpSend_command);
|
|
|
096905 |
--
|
|
|
096905 |
2.13.5
|
|
|
096905 |
|
|
|
096905 |
|
|
|
096905 |
From fc0d9df034e8701cdcf6c24fd40b1dbc8bc3e084 Mon Sep 17 00:00:00 2001
|
|
|
096905 |
From: Marc Hoersken <info@marc-hoersken.de>
|
|
|
096905 |
Date: Mon, 23 Mar 2015 23:17:31 +0100
|
|
|
096905 |
Subject: [PATCH 4/5] scp.c: improved command length calculation
|
|
|
096905 |
|
|
|
096905 |
Reduced number of calls to strlen, because shell_quotearg already
|
|
|
096905 |
returns the length of the resulting string (e.q. quoted path)
|
|
|
096905 |
which we can add to the existing and known cmd_len.
|
|
|
096905 |
Removed obsolete call to memset again, because we can put a final
|
|
|
096905 |
NULL-byte at the end of the string using the calculated length.
|
|
|
096905 |
|
|
|
096905 |
Upstream-commit: 3d3347c0625ce29b5581a0aa45e6e3be580769f1
|
|
|
096905 |
Signed-off-by: Kamil Dudka <kdudka@redhat.com>
|
|
|
096905 |
---
|
|
|
096905 |
src/scp.c | 32 ++++++++++----------------------
|
|
|
096905 |
1 file changed, 10 insertions(+), 22 deletions(-)
|
|
|
096905 |
|
|
|
096905 |
diff --git a/src/scp.c b/src/scp.c
|
|
|
096905 |
index 30d46af..f3d4995 100644
|
|
|
096905 |
--- a/src/scp.c
|
|
|
096905 |
+++ b/src/scp.c
|
|
|
096905 |
@@ -299,18 +299,12 @@ scp_recv(LIBSSH2_SESSION * session, const char *path, struct stat * sb)
|
|
|
096905 |
"scp -%sf ", sb?"p":"");
|
|
|
096905 |
|
|
|
096905 |
cmd_len = strlen((char *)session->scpRecv_command);
|
|
|
096905 |
+ cmd_len += shell_quotearg(path,
|
|
|
096905 |
+ &session->scpRecv_command[cmd_len],
|
|
|
096905 |
+ session->scpRecv_command_len - cmd_len);
|
|
|
096905 |
|
|
|
096905 |
- memset(&session->scpRecv_command[cmd_len], 0,
|
|
|
096905 |
- session->scpRecv_command_len - cmd_len);
|
|
|
096905 |
-
|
|
|
096905 |
- (void)shell_quotearg(path,
|
|
|
096905 |
- &session->scpRecv_command[cmd_len],
|
|
|
096905 |
- session->scpRecv_command_len - cmd_len);
|
|
|
096905 |
-
|
|
|
096905 |
- session->scpRecv_command[session->scpRecv_command_len - 1] = '\0';
|
|
|
096905 |
-
|
|
|
096905 |
- session->scpRecv_command_len =
|
|
|
096905 |
- strlen((char *)session->scpRecv_command);
|
|
|
096905 |
+ session->scpRecv_command[cmd_len] = '\0';
|
|
|
096905 |
+ session->scpRecv_command_len = cmd_len + 1;
|
|
|
096905 |
|
|
|
096905 |
_libssh2_debug(session, LIBSSH2_TRACE_SCP,
|
|
|
096905 |
"Opening channel for SCP receive");
|
|
|
096905 |
@@ -811,18 +805,12 @@ scp_send(LIBSSH2_SESSION * session, const char *path, int mode,
|
|
|
096905 |
"scp -%st ", (mtime || atime)?"p":"");
|
|
|
096905 |
|
|
|
096905 |
cmd_len = strlen((char *)session->scpSend_command);
|
|
|
096905 |
+ cmd_len += shell_quotearg(path,
|
|
|
096905 |
+ &session->scpSend_command[cmd_len],
|
|
|
096905 |
+ session->scpSend_command_len - cmd_len);
|
|
|
096905 |
|
|
|
096905 |
- memset(&session->scpSend_command[cmd_len], 0,
|
|
|
096905 |
- session->scpSend_command_len - cmd_len);
|
|
|
096905 |
-
|
|
|
096905 |
- (void)shell_quotearg(path,
|
|
|
096905 |
- &session->scpSend_command[cmd_len],
|
|
|
096905 |
- session->scpSend_command_len - cmd_len);
|
|
|
096905 |
-
|
|
|
096905 |
- session->scpSend_command[session->scpSend_command_len - 1] = '\0';
|
|
|
096905 |
-
|
|
|
096905 |
- session->scpSend_command_len =
|
|
|
096905 |
- strlen((char *)session->scpSend_command);
|
|
|
096905 |
+ session->scpSend_command[cmd_len] = '\0';
|
|
|
096905 |
+ session->scpSend_command_len = cmd_len + 1;
|
|
|
096905 |
|
|
|
096905 |
_libssh2_debug(session, LIBSSH2_TRACE_SCP,
|
|
|
096905 |
"Opening channel for SCP send");
|
|
|
096905 |
--
|
|
|
096905 |
2.13.5
|
|
|
096905 |
|
|
|
096905 |
|
|
|
096905 |
From 9506e299fa5116aa8c4c626e6de1feaed9ff9ff8 Mon Sep 17 00:00:00 2001
|
|
|
096905 |
From: Kamil Dudka <kdudka@redhat.com>
|
|
|
096905 |
Date: Mon, 11 Sep 2017 21:13:45 +0200
|
|
|
096905 |
Subject: [PATCH 5/5] scp: do not NUL-terminate the command for remote exec
|
|
|
096905 |
(#208)
|
|
|
096905 |
|
|
|
096905 |
It breaks SCP download/upload from/to certain server implementations.
|
|
|
096905 |
|
|
|
096905 |
The bug does not manifest with OpenSSH, which silently drops the NUL
|
|
|
096905 |
byte (eventually with any garbage that follows the NUL byte) before
|
|
|
096905 |
executing it.
|
|
|
096905 |
|
|
|
096905 |
Bug: https://bugzilla.redhat.com/1489736
|
|
|
096905 |
|
|
|
096905 |
Upstream-commit: 819ef4f2037490b6aa2e870aea851b6364184090
|
|
|
096905 |
Signed-off-by: Kamil Dudka <kdudka@redhat.com>
|
|
|
096905 |
---
|
|
|
096905 |
src/scp.c | 8 ++++----
|
|
|
096905 |
1 file changed, 4 insertions(+), 4 deletions(-)
|
|
|
096905 |
|
|
|
096905 |
diff --git a/src/scp.c b/src/scp.c
|
|
|
096905 |
index f3d4995..c6451bc 100644
|
|
|
096905 |
--- a/src/scp.c
|
|
|
096905 |
+++ b/src/scp.c
|
|
|
096905 |
@@ -303,8 +303,8 @@ scp_recv(LIBSSH2_SESSION * session, const char *path, struct stat * sb)
|
|
|
096905 |
&session->scpRecv_command[cmd_len],
|
|
|
096905 |
session->scpRecv_command_len - cmd_len);
|
|
|
096905 |
|
|
|
096905 |
- session->scpRecv_command[cmd_len] = '\0';
|
|
|
096905 |
- session->scpRecv_command_len = cmd_len + 1;
|
|
|
096905 |
+ /* the command to exec should _not_ be NUL-terminated */
|
|
|
096905 |
+ session->scpRecv_command_len = cmd_len;
|
|
|
096905 |
|
|
|
096905 |
_libssh2_debug(session, LIBSSH2_TRACE_SCP,
|
|
|
096905 |
"Opening channel for SCP receive");
|
|
|
096905 |
@@ -809,8 +809,8 @@ scp_send(LIBSSH2_SESSION * session, const char *path, int mode,
|
|
|
096905 |
&session->scpSend_command[cmd_len],
|
|
|
096905 |
session->scpSend_command_len - cmd_len);
|
|
|
096905 |
|
|
|
096905 |
- session->scpSend_command[cmd_len] = '\0';
|
|
|
096905 |
- session->scpSend_command_len = cmd_len + 1;
|
|
|
096905 |
+ /* the command to exec should _not_ be NUL-terminated */
|
|
|
096905 |
+ session->scpSend_command_len = cmd_len;
|
|
|
096905 |
|
|
|
096905 |
_libssh2_debug(session, LIBSSH2_TRACE_SCP,
|
|
|
096905 |
"Opening channel for SCP send");
|
|
|
096905 |
--
|
|
|
096905 |
2.13.5
|
|
|
096905 |
|