summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDamien Miller <djm@cvs.openbsd.org>2003-01-10 10:29:36 +0000
committerDamien Miller <djm@cvs.openbsd.org>2003-01-10 10:29:36 +0000
commit9ffdb0d0822d73c6a4da81a746a9b92578e4680b (patch)
tree12736a6f8faab31447e2297aace689405757e093
parent97dcae600045f281b5367ec69612a11e129eecf4 (diff)
Don't ftruncate after write error, creating sparse files of incorrect length
mindrot bug #403, reported by rusr@cup.hp.com; ok markus@
-rw-r--r--bin/rcp/rcp.c4
-rw-r--r--usr.bin/ssh/scp.c4
2 files changed, 4 insertions, 4 deletions
diff --git a/bin/rcp/rcp.c b/bin/rcp/rcp.c
index b237e3311e5..0f44b717da9 100644
--- a/bin/rcp/rcp.c
+++ b/bin/rcp/rcp.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: rcp.c,v 1.31 2002/07/04 04:26:40 deraadt Exp $ */
+/* $OpenBSD: rcp.c,v 1.32 2003/01/10 10:29:35 djm Exp $ */
/* $NetBSD: rcp.c,v 1.9 1995/03/21 08:19:06 cgd Exp $ */
/*
@@ -731,7 +731,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;
}
diff --git a/usr.bin/ssh/scp.c b/usr.bin/ssh/scp.c
index f423f461e7e..feb96521b2c 100644
--- a/usr.bin/ssh/scp.c
+++ b/usr.bin/ssh/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"
@@ -848,7 +848,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;
}