Don't delete outfile unconditionally.
MFC after: 1 month
This commit is contained in:
parent
f32fbc84bd
commit
b393a8ace6
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=336121
@ -1429,6 +1429,7 @@ file_uncompress(char *file, char *outfile, size_t outsize)
|
|||||||
unsigned char header1[4];
|
unsigned char header1[4];
|
||||||
enum filetype method;
|
enum filetype method;
|
||||||
int fd, ofd, zfd = -1;
|
int fd, ofd, zfd = -1;
|
||||||
|
int err;
|
||||||
size_t in_size;
|
size_t in_size;
|
||||||
#ifndef SMALL
|
#ifndef SMALL
|
||||||
ssize_t rv;
|
ssize_t rv;
|
||||||
@ -1601,14 +1602,21 @@ file_uncompress(char *file, char *outfile, size_t outsize)
|
|||||||
|
|
||||||
size = zuncompress(in, out, NULL, 0, NULL);
|
size = zuncompress(in, out, NULL, 0, NULL);
|
||||||
/* need to fclose() if ferror() is true... */
|
/* need to fclose() if ferror() is true... */
|
||||||
if (ferror(in) | fclose(in)) {
|
err = ferror(in);
|
||||||
maybe_warn("failed infile fclose");
|
if (err | fclose(in)) {
|
||||||
unlink(outfile);
|
if (err)
|
||||||
|
maybe_warn("failed infile");
|
||||||
|
else
|
||||||
|
maybe_warn("failed infile fclose");
|
||||||
|
if (cflag == 0)
|
||||||
|
unlink(outfile);
|
||||||
(void)fclose(out);
|
(void)fclose(out);
|
||||||
|
goto lose;
|
||||||
}
|
}
|
||||||
if (fclose(out) != 0) {
|
if (fclose(out) != 0) {
|
||||||
maybe_warn("failed outfile fclose");
|
maybe_warn("failed outfile fclose");
|
||||||
unlink(outfile);
|
if (cflag == 0)
|
||||||
|
unlink(outfile);
|
||||||
goto lose;
|
goto lose;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
Loading…
Reference in New Issue
Block a user