• R/O
  • HTTP
  • SSH
  • HTTPS

コミット

タグ
未設定

よく使われているワード(クリックで追加)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

system/corennnnn


コミットメタ情報

リビジョン287c71ca84533da008e9cc240224910a9d05139e (tree)
日時2009-06-17 09:36:04
作者Doug Zongker <dougz@andr...>
コミッターDoug Zongker

ログメッセージ

fix decompression bug in fastboot

fastboot passes the *uncompressed* length of the file as the length of
the input to the inflate() call, which happens to work unless the
compressed data is actually larger than the uncompressed data (which
it can be for very small files). Fix this to pass the correct
compressed length down to the inflate call.

変更サマリ

差分

--- a/libzipfile/centraldir.c
+++ b/libzipfile/centraldir.c
@@ -13,7 +13,7 @@ enum {
1313 // central directory entries
1414 ENTRY_SIGNATURE = 0x02014b50,
1515 ENTRY_LEN = 46, // CentralDirEnt len, excl. var fields
16-
16+
1717 // local file header
1818 LFH_SIZE = 30,
1919 };
@@ -73,8 +73,6 @@ read_central_directory_entry(Zipfile* file, Zipentry* entry,
7373 unsigned short lastModFileTime;
7474 unsigned short lastModFileDate;
7575 unsigned long crc32;
76- unsigned long compressedSize;
77- unsigned long uncompressedSize;
7876 unsigned short extraFieldLength;
7977 unsigned short fileCommentLength;
8078 unsigned short diskNumberStart;
@@ -85,7 +83,7 @@ read_central_directory_entry(Zipfile* file, Zipentry* entry,
8583 const unsigned char* fileComment;
8684 unsigned int dataOffset;
8785 unsigned short lfhExtraFieldSize;
88-
86+
8987
9088 p = *buf;
9189
@@ -106,7 +104,7 @@ read_central_directory_entry(Zipfile* file, Zipentry* entry,
106104 lastModFileTime = read_le_short(&p[0x0c]);
107105 lastModFileDate = read_le_short(&p[0x0e]);
108106 crc32 = read_le_int(&p[0x10]);
109- compressedSize = read_le_int(&p[0x14]);
107+ entry->compressedSize = read_le_int(&p[0x14]);
110108 entry->uncompressedSize = read_le_int(&p[0x18]);
111109 entry->fileNameLength = read_le_short(&p[0x1c]);
112110 extraFieldLength = read_le_short(&p[0x1e]);
@@ -141,14 +139,14 @@ read_central_directory_entry(Zipfile* file, Zipentry* entry,
141139 fileComment = NULL;
142140 }
143141 p += fileCommentLength;
144-
142+
145143 *buf = p;
146144
147145 // the size of the extraField in the central dir is how much data there is,
148146 // but the one in the local file header also contains some padding.
149147 p = file->buf + localHeaderRelOffset;
150148 extraFieldLength = read_le_short(&p[0x1c]);
151-
149+
152150 dataOffset = localHeaderRelOffset + LFH_SIZE
153151 + entry->fileNameLength + extraFieldLength;
154152 entry->data = file->buf + dataOffset;
@@ -243,7 +241,7 @@ read_central_dir(Zipfile *file)
243241 free(entry);
244242 goto bail;
245243 }
246-
244+
247245 // add it to our list
248246 entry->next = file->entries;
249247 file->entries = entry;
@@ -253,4 +251,3 @@ read_central_dir(Zipfile *file)
253251 bail:
254252 return -1;
255253 }
256-
--- a/libzipfile/zipfile.c
+++ b/libzipfile/zipfile.c
@@ -82,13 +82,13 @@ uninflate(unsigned char* out, int unlen, const unsigned char* in, int clen)
8282 unsigned long crc;
8383 int err = 0;
8484 int zerr;
85-
85+
8686 memset(&zstream, 0, sizeof(zstream));
8787 zstream.zalloc = Z_NULL;
8888 zstream.zfree = Z_NULL;
8989 zstream.opaque = Z_NULL;
9090 zstream.next_in = (void*)in;
91- zstream.avail_in = unlen;
91+ zstream.avail_in = clen;
9292 zstream.next_out = (Bytef*) out;
9393 zstream.avail_out = unlen;
9494 zstream.data_type = Z_UNKNOWN;
@@ -99,7 +99,7 @@ uninflate(unsigned char* out, int unlen, const unsigned char* in, int clen)
9999 if (zerr != Z_OK) {
100100 return -1;
101101 }
102-
102+
103103 // uncompress the data
104104 zerr = inflate(&zstream, Z_FINISH);
105105 if (zerr != Z_STREAM_END) {
@@ -107,7 +107,7 @@ uninflate(unsigned char* out, int unlen, const unsigned char* in, int clen)
107107 zstream.total_out);
108108 err = -1;
109109 }
110-
110+
111111 inflateEnd(&zstream);
112112 return err;
113113 }