diff options
author | Elliott Hughes <enh@google.com> | 2015-04-30 06:44:20 +0200 |
---|---|---|
committer | Android Git Automerger <android-git-automerger@android.com> | 2015-04-30 06:44:20 +0200 |
commit | b2007b70cafac781565ab20c299353cfb0415f71 (patch) | |
tree | e2c357667b0e76e6fa5a43c7a7951c872c373e9c /minzip | |
parent | am 15a2e46b: am f7466f9f: Stop using adb_strtok, and check argument validity. (diff) | |
parent | am 34d3a3d0: am 34c7731a: Merge "Check all lseek calls succeed." (diff) | |
download | android_bootable_recovery-b2007b70cafac781565ab20c299353cfb0415f71.tar android_bootable_recovery-b2007b70cafac781565ab20c299353cfb0415f71.tar.gz android_bootable_recovery-b2007b70cafac781565ab20c299353cfb0415f71.tar.bz2 android_bootable_recovery-b2007b70cafac781565ab20c299353cfb0415f71.tar.lz android_bootable_recovery-b2007b70cafac781565ab20c299353cfb0415f71.tar.xz android_bootable_recovery-b2007b70cafac781565ab20c299353cfb0415f71.tar.zst android_bootable_recovery-b2007b70cafac781565ab20c299353cfb0415f71.zip |
Diffstat (limited to 'minzip')
-rw-r--r-- | minzip/SysUtil.c | 10 | ||||
-rw-r--r-- | minzip/Zip.c | 6 |
2 files changed, 8 insertions, 8 deletions
diff --git a/minzip/SysUtil.c b/minzip/SysUtil.c index ac6f5c33f..b160c9e3d 100644 --- a/minzip/SysUtil.c +++ b/minzip/SysUtil.c @@ -27,11 +27,13 @@ static int getFileStartAndLength(int fd, off_t *start_, size_t *length_) assert(start_ != NULL); assert(length_ != NULL); - start = lseek(fd, 0L, SEEK_CUR); - end = lseek(fd, 0L, SEEK_END); - (void) lseek(fd, start, SEEK_SET); + // TODO: isn't start always 0 for the single call site? just use fstat instead? - if (start == (off_t) -1 || end == (off_t) -1) { + start = TEMP_FAILURE_RETRY(lseek(fd, 0L, SEEK_CUR)); + end = TEMP_FAILURE_RETRY(lseek(fd, 0L, SEEK_END)); + + if (TEMP_FAILURE_RETRY(lseek(fd, start, SEEK_SET)) == -1 || + start == (off_t) -1 || end == (off_t) -1) { LOGE("could not determine length of file\n"); return -1; } diff --git a/minzip/Zip.c b/minzip/Zip.c index d3ff79be6..40712e03a 100644 --- a/minzip/Zip.c +++ b/minzip/Zip.c @@ -675,13 +675,11 @@ static bool writeProcessFunction(const unsigned char *data, int dataLen, } ssize_t soFar = 0; while (true) { - ssize_t n = write(fd, data+soFar, dataLen-soFar); + ssize_t n = TEMP_FAILURE_RETRY(write(fd, data+soFar, dataLen-soFar)); if (n <= 0) { LOGE("Error writing %zd bytes from zip file from %p: %s\n", dataLen-soFar, data+soFar, strerror(errno)); - if (errno != EINTR) { - return false; - } + return false; } else if (n > 0) { soFar += n; if (soFar == dataLen) return true; |