summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Runge <mrunge@google.com>2014-10-31 01:26:30 +0100
committerAndroid Git Automerger <android-git-automerger@android.com>2014-10-31 01:26:30 +0100
commit60a473d29805bee9e93c96f0e552582377c37cc7 (patch)
tree032eb9d6b0344399e6587eb1da2a14215eae89a5
parentadbd: Support for new f_fs descriptor format (diff)
parentam e908a454: am 042c3cd0: Force sync files written by minzip. (diff)
downloadandroid_bootable_recovery-60a473d29805bee9e93c96f0e552582377c37cc7.tar
android_bootable_recovery-60a473d29805bee9e93c96f0e552582377c37cc7.tar.gz
android_bootable_recovery-60a473d29805bee9e93c96f0e552582377c37cc7.tar.bz2
android_bootable_recovery-60a473d29805bee9e93c96f0e552582377c37cc7.tar.lz
android_bootable_recovery-60a473d29805bee9e93c96f0e552582377c37cc7.tar.xz
android_bootable_recovery-60a473d29805bee9e93c96f0e552582377c37cc7.tar.zst
android_bootable_recovery-60a473d29805bee9e93c96f0e552582377c37cc7.zip
-rw-r--r--minzip/Zip.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/minzip/Zip.c b/minzip/Zip.c
index 5070104d3..70aff00cd 100644
--- a/minzip/Zip.c
+++ b/minzip/Zip.c
@@ -1067,7 +1067,8 @@ bool mzExtractRecursive(const ZipArchive *pArchive,
setfscreatecon(secontext);
}
- int fd = creat(targetFile, UNZIP_FILEMODE);
+ int fd = open(targetFile, O_CREAT|O_WRONLY|O_TRUNC|O_SYNC
+ , UNZIP_FILEMODE);
if (secontext) {
freecon(secontext);
@@ -1082,7 +1083,12 @@ bool mzExtractRecursive(const ZipArchive *pArchive,
}
bool ok = mzExtractZipEntryToFile(pArchive, pEntry, fd);
- close(fd);
+ if (ok) {
+ ok = (fsync(fd) == 0);
+ }
+ if (close(fd) != 0) {
+ ok = false;
+ }
if (!ok) {
LOGE("Error extracting \"%s\"\n", targetFile);
ok = false;