From b6beaff152c22af1b998cf05c5a1fa0c8d9f3e0b Mon Sep 17 00:00:00 2001 From: Damien Miller Date: Wed, 13 Jun 2007 00:21:28 +0000 Subject: don't ftruncate() non-regular files; bz#1236 reported by wood AT xmission.com; ok dtucker@ --- usr.bin/ssh/scp.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'usr.bin/ssh/scp.c') diff --git a/usr.bin/ssh/scp.c b/usr.bin/ssh/scp.c index 619c43fe7de..e250272d879 100644 --- a/usr.bin/ssh/scp.c +++ b/usr.bin/ssh/scp.c @@ -1,4 +1,4 @@ -/* $OpenBSD: scp.c,v 1.158 2007/06/12 13:54:28 dtucker Exp $ */ +/* $OpenBSD: scp.c,v 1.159 2007/06/13 00:21:27 djm Exp $ */ /* * scp - secure remote copy. This is basically patched BSD rcp which * uses ssh to do the data transfer (instead of using rcmd). @@ -1009,7 +1009,8 @@ bad: run_err("%s: %s", np, strerror(errno)); wrerr = YES; wrerrno = errno; } - if (wrerr == NO && ftruncate(ofd, size) != 0) { + if (wrerr == NO && (!exists || S_ISREG(stb.st_mode)) && + ftruncate(ofd, size) != 0) { run_err("%s: truncate: %s", np, strerror(errno)); wrerr = DISPLAYED; } -- cgit v1.2.3