Mercurial > illumos > illumos-gate
changeset 9650:2b8297304317
6823839 encrypt utility can cause loss of data
author | Valerie Bubb Fenwick <Valerie.Fenwick@Sun.COM> |
---|---|
date | Mon, 18 May 2009 15:11:14 -0700 |
parents | 3e6e0823be10 |
children | ca22f7d7086c |
files | usr/src/cmd/cmd-crypto/decrypt/decrypt.c |
diffstat | 1 files changed, 5 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/usr/src/cmd/cmd-crypto/decrypt/decrypt.c Mon May 18 17:38:43 2009 -0400 +++ b/usr/src/cmd/cmd-crypto/decrypt/decrypt.c Mon May 18 15:11:14 2009 -0700 @@ -433,6 +433,7 @@ char *outfilename = NULL; boolean_t errflag = B_TRUE; boolean_t inoutsame = B_FALSE; /* if both input & output are same */ + boolean_t leavefilealone = B_FALSE; CK_BYTE_PTR pivbuf = NULL_PTR; CK_ULONG ivlen = 0L; int mech_match = 0; @@ -717,6 +718,8 @@ cryptoerror(LOG_STDERR, gettext( "cannot open output file %s"), outfilename); + /* Cannot open file, should leave it alone */ + leavefilealone = B_TRUE; goto cleanup; } } @@ -977,8 +980,8 @@ } } - /* If error occurred, remove the output file */ - if (errflag && outfilename != NULL) { + /* If error occurred and the file was new, remove the output file */ + if (errflag && (outfilename != NULL) && !leavefilealone) { (void) unlink(outfilename); }