- OpenBSD CVS Sync:
   - reinhard@cvs.openbsd.org        2001/02/17 08:24:40
     [sftp.1]
     typo
   - deraadt@cvs.openbsd.org 2001/02/17 16:28:58
     [ssh.c]
     cleanup -V output; noted by millert
   - deraadt@cvs.openbsd.org 2001/02/17 16:48:48
     [sshd.8]
     it's the OpenSSH one
   - markus@cvs.openbsd.org  2001/02/18 11:33:54
     [dispatch.c]
     typo, SSH2_MSG_KEXINIT, from aspa@kronodoc.fi
   - markus@cvs.openbsd.org  2001/02/19 02:53:32
     [compat.c compat.h serverloop.c]
     ssh-1.2.{18-22} has broken handling of ignore messages; report from
     itojun@
   - markus@cvs.openbsd.org  2001/02/19 03:35:23
     [version.h]
     OpenSSH_2.5.1 adds bug compat with 1.2.{18-22}
   - deraadt@cvs.openbsd.org 2001/02/19 03:36:25
     [scp.c]
     np is changed by recursion; vinschen@redhat.com
diff --git a/compat.c b/compat.c
index 8334099..82f3df8 100644
--- a/compat.c
+++ b/compat.c
@@ -23,7 +23,7 @@
  */
 
 #include "includes.h"
-RCSID("$OpenBSD: compat.c,v 1.34 2001/01/21 19:05:48 markus Exp $");
+RCSID("$OpenBSD: compat.c,v 1.35 2001/02/19 09:53:31 markus Exp $");
 
 #ifdef HAVE_LIBPCRE
 #  include <pcreposix.h>
@@ -86,6 +86,8 @@
 		{ "^2\\.4$",		SSH_OLD_SESSIONID}, /* Van Dyke */
 		{ "^3\\.0 SecureCRT",	SSH_OLD_SESSIONID},
 		{ "^1\\.7 SecureFX",	SSH_OLD_SESSIONID},
+		{ "^1\\.2\\.1[89]",	SSH_BUG_IGNOREMSG},
+		{ "^1\\.2\\.2[012]",	SSH_BUG_IGNOREMSG},
 		{ NULL,			0 }
 	};
 	/* process table, return first match */
diff --git a/compat.h b/compat.h
index fb65cd6..2726faf 100644
--- a/compat.h
+++ b/compat.h
@@ -21,7 +21,7 @@
  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
-/* RCSID("$OpenBSD: compat.h,v 1.14 2001/01/08 22:29:05 markus Exp $"); */
+/* RCSID("$OpenBSD: compat.h,v 1.15 2001/02/19 09:53:31 markus Exp $"); */
 
 #ifndef COMPAT_H
 #define COMPAT_H
@@ -31,14 +31,15 @@
 #define	SSH_PROTO_1_PREFERRED	0x02
 #define	SSH_PROTO_2		0x04
 
-#define SSH_BUG_SIGBLOB		0x01
-#define SSH_BUG_PKSERVICE	0x02
-#define SSH_BUG_HMAC		0x04
-#define SSH_BUG_X11FWD		0x08
-#define SSH_OLD_SESSIONID	0x10
-#define SSH_BUG_PKAUTH		0x20
-#define SSH_BUG_DEBUG		0x40
-#define SSH_BUG_BANNER		0x80
+#define SSH_BUG_SIGBLOB		0x0001
+#define SSH_BUG_PKSERVICE	0x0002
+#define SSH_BUG_HMAC		0x0004
+#define SSH_BUG_X11FWD		0x0008
+#define SSH_OLD_SESSIONID	0x0010
+#define SSH_BUG_PKAUTH		0x0020
+#define SSH_BUG_DEBUG		0x0040
+#define SSH_BUG_BANNER		0x0080
+#define SSH_BUG_IGNOREMSG	0x0100
 
 void    enable_compat13(void);
 void    enable_compat20(void);
diff --git a/dispatch.c b/dispatch.c
index f0437cd..7168d1c 100644
--- a/dispatch.c
+++ b/dispatch.c
@@ -22,7 +22,7 @@
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 #include "includes.h"
-RCSID("$OpenBSD: dispatch.c,v 1.9 2001/02/04 15:32:23 stevesk Exp $");
+RCSID("$OpenBSD: dispatch.c,v 1.10 2001/02/18 18:33:53 markus Exp $");
 
 #include "ssh1.h"
 #include "ssh2.h"
@@ -40,7 +40,7 @@
 dispatch_protocol_error(int type, int plen, void *ctxt)
 {
 	error("Hm, dispatch protocol error: type %d plen %d", type, plen);
-	if (compat20 && type == SSH2_MSG_KEXDH_INIT)
+	if (compat20 && type == SSH2_MSG_KEXINIT)
 		fatal("dispatch_protocol_error: rekeying is not supported");
 }
 void
diff --git a/scp.c b/scp.c
index 3ca110b..541ba87 100644
--- a/scp.c
+++ b/scp.c
@@ -75,7 +75,7 @@
  */
 
 #include "includes.h"
-RCSID("$OpenBSD: scp.c,v 1.58 2001/02/10 15:14:11 danh Exp $");
+RCSID("$OpenBSD: scp.c,v 1.59 2001/02/19 10:36:25 deraadt Exp $");
 
 #include "xmalloc.h"
 #include "atomicio.h"
@@ -802,16 +802,16 @@
 			}
 			vect[0] = xstrdup(np);
 			sink(1, vect);
-			if (vect[0])
-				xfree(vect[0]);
 			if (setimes) {
 				setimes = 0;
-				if (utimes(np, tv) < 0)
+				if (utimes(vect[0], tv) < 0)
 					run_err("%s: set times: %s",
-						np, strerror(errno));
+					    vect[0], strerror(errno));
 			}
 			if (mod_flag)
-				(void) chmod(np, mode);
+				(void) chmod(vect[0], mode);
+			if (vect[0])
+				xfree(vect[0]);
 			continue;
 		}
 		omode = mode;
diff --git a/serverloop.c b/serverloop.c
index 79dbe79..fed943f 100644
--- a/serverloop.c
+++ b/serverloop.c
@@ -35,7 +35,7 @@
  */
 
 #include "includes.h"
-RCSID("$OpenBSD: serverloop.c,v 1.49 2001/02/15 23:19:59 markus Exp $");
+RCSID("$OpenBSD: serverloop.c,v 1.50 2001/02/19 09:53:32 markus Exp $");
 
 #include "xmalloc.h"
 #include "packet.h"
@@ -70,6 +70,7 @@
 static int stdin_eof = 0;	/* EOF message received from client. */
 static int fdout_eof = 0;	/* EOF encountered reading from fdout. */
 static int fderr_eof = 0;	/* EOF encountered readung from fderr. */
+static int fdin_is_tty = 0;	/* fdin points to a tty. */
 static int connection_in;	/* Connection to client (input). */
 static int connection_out;	/* Connection to client (output). */
 static u_int buffer_high;/* "Soft" max buffer size. */
@@ -338,7 +339,7 @@
 			fdin = -1;
 		} else {
 			/* Successful write. */
-			if (tcgetattr(fdin, &tio) == 0 &&
+			if (fdin_is_tty && tcgetattr(fdin, &tio) == 0 &&
 			    !(tio.c_lflag & ECHO) && (tio.c_lflag & ICANON)) {
 				/*
 				 * Simulate echo to reduce the impact of
@@ -435,6 +436,9 @@
 	if (fderr != -1)
 		set_nonblock(fderr);
 
+	if (!(datafellows & SSH_BUG_IGNOREMSG) && isatty(fdin))
+		fdin_is_tty = 1;
+
 	connection_in = packet_get_connection_in();
 	connection_out = packet_get_connection_out();
 
diff --git a/sftp.1 b/sftp.1
index 635c07b..6956ab4 100644
--- a/sftp.1
+++ b/sftp.1
@@ -1,4 +1,4 @@
-.\" $OpenBSD: sftp.1,v 1.7 2001/02/14 09:46:03 djm Exp $
+.\" $OpenBSD: sftp.1,v 1.8 2001/02/17 15:24:40 reinhard Exp $
 .\"
 .\" Copyright (c) 2001 Damien Miller. All rights reserved.
 .\"
@@ -27,7 +27,7 @@
 .Os
 .Sh NAME
 .Nm sftp
-.Nd Secure file tranfer program
+.Nd Secure file transfer program
 .Sh SYNOPSIS
 .Nm sftp
 .Op Fl vC
diff --git a/ssh.c b/ssh.c
index 1b02240..9e5ca11 100644
--- a/ssh.c
+++ b/ssh.c
@@ -39,7 +39,7 @@
  */
 
 #include "includes.h"
-RCSID("$OpenBSD: ssh.c,v 1.95 2001/02/11 12:59:25 markus Exp $");
+RCSID("$OpenBSD: ssh.c,v 1.96 2001/02/17 23:28:58 deraadt Exp $");
 
 #include <openssl/evp.h>
 #include <openssl/err.h>
@@ -391,11 +391,12 @@
 			}
 			/* fallthrough */
 		case 'V':
-			fprintf(stderr, "SSH Version %s, protocol versions %d.%d/%d.%d.\n",
+			fprintf(stderr,
+			    "%s, SSH protocols %d.%d/%d.%d, OpenSSL 0x%8.8lx\n",
 			    SSH_VERSION,
 			    PROTOCOL_MAJOR_1, PROTOCOL_MINOR_1,
-			    PROTOCOL_MAJOR_2, PROTOCOL_MINOR_2);
-			fprintf(stderr, "Compiled with SSL (0x%8.8lx).\n", SSLeay());
+			    PROTOCOL_MAJOR_2, PROTOCOL_MINOR_2,
+			    SSLeay());
 			if (opt == 'V')
 				exit(0);
 			break;
diff --git a/version.h b/version.h
index 3de8c01..83e086c 100644
--- a/version.h
+++ b/version.h
@@ -1,3 +1,3 @@
-/* $OpenBSD: version.h,v 1.18 2001/02/16 14:26:57 markus Exp $ */
+/* $OpenBSD: version.h,v 1.19 2001/02/19 10:35:23 markus Exp $ */
   
-#define SSH_VERSION	"OpenSSH_2.5.0p1"
+#define SSH_VERSION	"OpenSSH_2.5.1p1"