upstream: Have sftp reject "-1" in the same way as ssh(1) and

scp(1) do instead of accepting and silently ignoring it since protocol 1
support has been removed.  Spotted by shivakumar2696 at gmail.com, ok
deraadt@

OpenBSD-Commit-ID: b79f95559a1c993214f4ec9ae3c34caa87e9d5de
This commit is contained in:
dtucker@openbsd.org 2020-02-26 11:46:51 +00:00 committed by Darren Tucker
parent ade8e67bb0
commit 9e3220b585
1 changed files with 4 additions and 7 deletions

11
sftp.c
View File

@ -1,4 +1,4 @@
/* $OpenBSD: sftp.c,v 1.197 2020/01/23 07:10:22 dtucker Exp $ */ /* $OpenBSD: sftp.c,v 1.198 2020/02/26 11:46:51 dtucker Exp $ */
/* /*
* Copyright (c) 2001-2004 Damien Miller <djm@openbsd.org> * Copyright (c) 2001-2004 Damien Miller <djm@openbsd.org>
* *
@ -2377,7 +2377,7 @@ main(int argc, char **argv)
{ {
int in, out, ch, err, tmp, port = -1; int in, out, ch, err, tmp, port = -1;
char *host = NULL, *user, *cp, *file2 = NULL; char *host = NULL, *user, *cp, *file2 = NULL;
int debug_level = 0, sshver = 2; int debug_level = 0;
char *file1 = NULL, *sftp_server = NULL; char *file1 = NULL, *sftp_server = NULL;
char *ssh_program = _PATH_SSH_PROGRAM, *sftp_direct = NULL; char *ssh_program = _PATH_SSH_PROGRAM, *sftp_direct = NULL;
const char *errstr; const char *errstr;
@ -2445,12 +2445,10 @@ main(int argc, char **argv)
debug_level++; debug_level++;
break; break;
case '1': case '1':
sshver = 1; fatal("SSH protocol v.1 is no longer supported");
if (sftp_server == NULL)
sftp_server = _PATH_SFTP_SERVER;
break; break;
case '2': case '2':
sshver = 2; /* accept silently */
break; break;
case 'a': case 'a':
global_aflag = 1; global_aflag = 1;
@ -2555,7 +2553,6 @@ main(int argc, char **argv)
addargs(&args, "-l"); addargs(&args, "-l");
addargs(&args, "%s", user); addargs(&args, "%s", user);
} }
addargs(&args, "-oProtocol %d", sshver);
/* no subsystem if the server-spec contains a '/' */ /* no subsystem if the server-spec contains a '/' */
if (sftp_server == NULL || strchr(sftp_server, '/') == NULL) if (sftp_server == NULL || strchr(sftp_server, '/') == NULL)