From 2e62be3c9c48ff7ff9dee56e36c806215fb69713 Mon Sep 17 00:00:00 2001 From: Moinak Ghosh Date: Thu, 29 Aug 2013 22:03:08 +0530 Subject: [PATCH] Truncate password file after zeroing. --- pcompress.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/pcompress.c b/pcompress.c index 10ed1d9..e5b8bc2 100644 --- a/pcompress.c +++ b/pcompress.c @@ -736,7 +736,7 @@ start_decompress(pc_ctx_t *pctx, const char *filename, const char *to_filename) return (1); } - if ((uncompfd = open(to_filename, O_WRONLY|O_CREAT|O_TRUNC, S_IRUSR | S_IWUSR)) == -1) { + if ((uncompfd = open(to_filename, O_WRONLY|O_CREAT|O_TRUNC, S_IRUSR|S_IWUSR)) == -1) { close(compfd); err_print(1, "Cannot open: %s", to_filename); return (1); @@ -863,7 +863,7 @@ start_decompress(pc_ctx_t *pctx, const char *filename, const char *to_filename) } /* - * Archives older than 5 did not support MACs. + * Archives older than version 5 did not support MACs. */ if (version < 5) pctx->mac_bytes = 0; @@ -988,6 +988,8 @@ start_decompress(pc_ctx_t *pctx, const char *filename, const char *to_filename) pw[pw_len-1] = '\0'; lseek(fd, 0, SEEK_SET); Write(fd, zero, pw_len); + len = ftruncate(fd, 0); + /*^^^ Make compiler happy. */ } else { pw_len = -1; }