From: Andrey Rys Date: Sun, 28 Nov 2021 13:12:27 +0000 (+0100) Subject: xexit: do post-crypt work only if exiting by system error or normally. X-Git-Url: https://jxself.org/git/?a=commitdiff_plain;h=f98c367a4cf1ed9f0c6d7620e3f1988596945495;p=tfcrypt.git xexit: do post-crypt work only if exiting by system error or normally. --- diff --git a/VERSION b/VERSION index 9e5feb5..abac1ea 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -46 +47 diff --git a/tfc_error.c b/tfc_error.c index f69fdbe..d74fd56 100644 --- a/tfc_error.c +++ b/tfc_error.c @@ -62,6 +62,8 @@ _ex: void xexit(int status) { + if (status > 1) goto _do_clean_and_exit; + xclose(sfd); if (do_ftrunc > TFC_NO_FTRUNC) { if (do_ftrunc == TFC_FTRUNC_TAIL) ftrunc_dfd = total_processed_dst; @@ -70,6 +72,7 @@ void xexit(int status) if (do_preserve_time) fcopy_matime(dfd, &s_stat); xclose(dfd); +_do_clean_and_exit: memset(srcblk, 0, sizeof(srcblk)); memset(dstblk, 0, sizeof(dstblk)); diff --git a/tfcrypt.c b/tfcrypt.c index df7cc29..6b9055f 100644 --- a/tfcrypt.c +++ b/tfcrypt.c @@ -37,7 +37,7 @@ static void open_log(const char *logfile) fd = open(logfile, O_WRONLY | O_CREAT | O_LARGEFILE | O_TRUNC, 0666); if (fd == -1) xerror(NO, NO, YES, "%s", logfile); xclose(2); - if (dup2(fd, 2) == -1) xerror(NO, NO, YES, "dup2(%d, 2) for %s", fd, logfile); + if (dup2(fd, 2) == -1) xexit(2); xclose(fd); do_statline_dynamic = NO; }