[openssh-commits] [openssh] 10/14: upstream: in olde-RCP protocol mode, don't allow embedded
git+noreply at mindrot.org
git+noreply at mindrot.org
Thu Nov 26 10:20:55 AEDT 2026
This is an automated email from the git hooks/post-receive script.
djm pushed a commit to branch master
in repository openssh.
commit 9778f4010c2595e02785f3f67af6b63996c622d9
Author: djm at openbsd.org <djm at openbsd.org>
AuthorDate: Wed Nov 25 21:21:51 2026 +0000
upstream: in olde-RCP protocol mode, don't allow embedded
newlines to corrupt control messages
Anthropic ANT-2026-O6FX9NNV
OpenBSD-Commit-ID: 5cb7a91bef842a53451ef260a3ac2a8e24ec0c67
---
scp.c | 26 ++++++++++++++++++++------
1 file changed, 20 insertions(+), 6 deletions(-)
diff --git a/scp.c b/scp.c
index a0ac3d629..cae9491d8 100644
--- a/scp.c
+++ b/scp.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: scp.c,v 1.279 2026/11/25 20:02:49 djm Exp $ */
+/* $OpenBSD: scp.c,v 1.280 2026/11/25 21:21:51 djm Exp $ */
/*
* scp - secure remote copy. This is basically patched BSD rcp which
* uses ssh to do the data transfer (instead of using rcmd).
@@ -2182,16 +2182,30 @@ run_err(const char *fmt,...)
{
static FILE *fp;
va_list ap;
+ char *msg, *encmsg;
+ size_t len;
++errs;
if (fp != NULL || (remout != -1 && (fp = fdopen(remout, "w")))) {
+ va_start(ap, fmt);
+ xvasprintf(&msg, fmt, ap);
+ va_end(ap);
+ /*
+ * Error messages are a single protocol record; a newline in
+ * the message (e.g. from a filename) would let the rest of
+ * it be parsed by the peer as further records.
+ */
+ if (strchr(msg, '\n') != NULL) {
+ len = strlen(msg) * 4 + 1;
+ encmsg = xmalloc(len);
+ strnvis(encmsg, msg, len, VIS_NL);
+ free(msg);
+ msg = encmsg;
+ }
(void) fprintf(fp, "%c", 0x01);
- (void) fprintf(fp, "scp: ");
- va_start(ap, fmt);
- (void) vfprintf(fp, fmt, ap);
- va_end(ap);
- (void) fprintf(fp, "\n");
+ (void) fprintf(fp, "scp: %s\n", msg);
(void) fflush(fp);
+ free(msg);
}
if (!iamremote) {
--
To stop receiving notification emails like this one, please contact
djm at mindrot.org.
More information about the openssh-commits
mailing list