diff options
author | Kenny Root <kroot@google.com> | 2010-09-24 15:22:38 -0700 |
---|---|---|
committer | Android Git Automerger <android-git-automerger@android.com> | 2010-09-24 15:22:38 -0700 |
commit | d6d93dbb86909747a5c7a8f363b28901dbb7422f (patch) | |
tree | 925dc4c21ca668700bc6c5256c5da05d63d1503d /libs/utils | |
parent | 68a63161cfbaf31a2e0cb886b0b3870d9da3ed99 (diff) | |
parent | 03944f29647fc432b22e6ec2412672cb6783a78e (diff) | |
download | frameworks_native-d6d93dbb86909747a5c7a8f363b28901dbb7422f.zip frameworks_native-d6d93dbb86909747a5c7a8f363b28901dbb7422f.tar.gz frameworks_native-d6d93dbb86909747a5c7a8f363b28901dbb7422f.tar.bz2 |
am 3e07c000: am 74865ef6: Merge "Add locking around ZIP seeking" into gingerbread
Merge commit '3e07c0007b10fbda945516acaf6b2a8787a6ca06'
* commit '3e07c0007b10fbda945516acaf6b2a8787a6ca06':
Add locking around ZIP seeking
Diffstat (limited to 'libs/utils')
-rw-r--r-- | libs/utils/ZipFileRO.cpp | 27 |
1 files changed, 17 insertions, 10 deletions
diff --git a/libs/utils/ZipFileRO.cpp b/libs/utils/ZipFileRO.cpp index 2d53136..59809c2 100644 --- a/libs/utils/ZipFileRO.cpp +++ b/libs/utils/ZipFileRO.cpp @@ -22,6 +22,7 @@ #include <utils/ZipFileRO.h> #include <utils/Log.h> #include <utils/misc.h> +#include <utils/threads.h> #include <zlib.h> @@ -195,7 +196,7 @@ bool ZipFileRO::mapCentralDirectory(void) free(scanBuf); return false; } else if (header != kLFHSignature) { - LOGV("Not a Zip archive (found 0x%08x)\n", val); + LOGV("Not a Zip archive (found 0x%08x)\n", header); free(scanBuf); return false; } @@ -496,15 +497,21 @@ bool ZipFileRO::getEntryInfo(ZipEntryRO entry, int* pMethod, size_t* pUncompLen, } unsigned char lfhBuf[kLFHLen]; - if (lseek(mFd, localHdrOffset, SEEK_SET) != localHdrOffset) { - LOGW("failed seeking to lfh at offset %ld\n", localHdrOffset); - return false; - } - ssize_t actual = - TEMP_FAILURE_RETRY(read(mFd, lfhBuf, sizeof(lfhBuf))); - if (actual != sizeof(lfhBuf)) { - LOGW("failed reading lfh from offset %ld\n", localHdrOffset); - return false; + + { + AutoMutex _l(mFdLock); + + if (lseek(mFd, localHdrOffset, SEEK_SET) != localHdrOffset) { + LOGW("failed seeking to lfh at offset %ld\n", localHdrOffset); + return false; + } + + ssize_t actual = + TEMP_FAILURE_RETRY(read(mFd, lfhBuf, sizeof(lfhBuf))); + if (actual != sizeof(lfhBuf)) { + LOGW("failed reading lfh from offset %ld\n", localHdrOffset); + return false; + } } if (get4LE(lfhBuf) != kLFHSignature) { |