From 86b781c179911d609bd0e3cfa3992f510cd56413 Mon Sep 17 00:00:00 2001 From: Damien Miller Date: Fri, 10 Jan 2003 21:44:48 +1100 Subject: [PATCH] - djm@cvs.openbsd.org 2003/01/10 10:29:35 [scp.c] Don't ftruncate after write error, creating sparse files of incorrect length mindrot bug #403, reported by rusr@cup.hp.com; ok markus@ --- ChangeLog | 7 ++++++- scp.c | 4 ++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index 595f1f6fc..26afd0929 100644 --- a/ChangeLog +++ b/ChangeLog @@ -17,6 +17,11 @@ [sftp-client.c] Simplify and avoid redundancy in packet send and receive functions; ok fgs@ + - djm@cvs.openbsd.org 2003/01/10 10:29:35 + [scp.c] + Don't ftruncate after write error, creating sparse files of + incorrect length + mindrot bug #403, reported by rusr@cup.hp.com; ok markus@ 20030108 - (djm) Sync openbsd-compat/ with OpenBSD -current @@ -985,4 +990,4 @@ save auth method before monitor_reset_key_state(); bugzilla bug #284; ok provos@ -$Id: ChangeLog,v 1.2561 2003/01/10 10:43:58 djm Exp $ +$Id: ChangeLog,v 1.2562 2003/01/10 10:44:48 djm Exp $ diff --git a/scp.c b/scp.c index 44b5b4582..616dd3783 100644 --- a/scp.c +++ b/scp.c @@ -75,7 +75,7 @@ */ #include "includes.h" -RCSID("$OpenBSD: scp.c,v 1.97 2003/01/10 08:19:07 fgsch Exp $"); +RCSID("$OpenBSD: scp.c,v 1.98 2003/01/10 10:29:35 djm Exp $"); #include "xmalloc.h" #include "atomicio.h" @@ -864,7 +864,7 @@ bad: run_err("%s: %s", np, strerror(errno)); wrerr = YES; wrerrno = j >= 0 ? EIO : errno; } - if (ftruncate(ofd, size)) { + if (wrerr == NO && ftruncate(ofd, size) != 0) { run_err("%s: truncate: %s", np, strerror(errno)); wrerr = DISPLAYED; }