We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents fe8563f + 042c3cd commit e908a45Copy full SHA for e908a45
minzip/Zip.c
@@ -1067,7 +1067,8 @@ bool mzExtractRecursive(const ZipArchive *pArchive,
1067
setfscreatecon(secontext);
1068
}
1069
1070
- int fd = creat(targetFile, UNZIP_FILEMODE);
+ int fd = open(targetFile, O_CREAT|O_WRONLY|O_TRUNC|O_SYNC
1071
+ , UNZIP_FILEMODE);
1072
1073
if (secontext) {
1074
freecon(secontext);
@@ -1082,7 +1083,12 @@ bool mzExtractRecursive(const ZipArchive *pArchive,
1082
1083
1084
1085
bool ok = mzExtractZipEntryToFile(pArchive, pEntry, fd);
- close(fd);
1086
+ if (ok) {
1087
+ ok = (fsync(fd) == 0);
1088
+ }
1089
+ if (close(fd) != 0) {
1090
+ ok = false;
1091
1092
if (!ok) {
1093
LOGE("Error extracting \"%s\"\n", targetFile);
1094
ok = false;
0 commit comments