diff options
author | Pierre Joye <pajoye@php.net> | 2008-08-07 23:24:11 +0000 |
---|---|---|
committer | Pierre Joye <pajoye@php.net> | 2008-08-07 23:24:11 +0000 |
commit | 490a34220583be5eee4ad2e8be56e9e285ec0e74 (patch) | |
tree | 8b67a365ee193b545a0c067c23c478e8d5fcbe06 /ext/zip/lib/zip_open.c | |
parent | c94f8b4a1cb303bebc22ca83d09a05064877bf4b (diff) | |
download | php-git-490a34220583be5eee4ad2e8be56e9e285ec0e74.tar.gz |
- MFH: update to 0.9 (torrentzip support, files open only when necessary), windows fixes
Diffstat (limited to 'ext/zip/lib/zip_open.c')
-rw-r--r-- | ext/zip/lib/zip_open.c | 23 |
1 files changed, 6 insertions, 17 deletions
diff --git a/ext/zip/lib/zip_open.c b/ext/zip/lib/zip_open.c index 7247b7b8d6..cb3e66d2ca 100644 --- a/ext/zip/lib/zip_open.c +++ b/ext/zip/lib/zip_open.c @@ -310,9 +310,8 @@ static void _zip_check_torrentzip(struct zip *za) { uLong crc_got, crc_should; + char buf[8+1]; char *end; - Bytef buf[BUFSIZE]; - unsigned int n, remain; if (za->zp == NULL || za->cdir == NULL) return; @@ -321,27 +320,17 @@ _zip_check_torrentzip(struct zip *za) || strncmp(za->cdir->comment, TORRENT_SIG, TORRENT_SIG_LEN) != 0) return; + memcpy(buf, za->cdir->comment+TORRENT_SIG_LEN, 8); + buf[8] = '\0'; errno = 0; - crc_should = strtoul(za->cdir->comment+TORRENT_SIG_LEN, &end, 16); + crc_should = strtoul(buf, &end, 16); if ((crc_should == UINT_MAX && errno != 0) || (end && *end)) return; - crc_got = crc32(0L, Z_NULL, 0); - - if (fseek(za->zp, za->cdir->offset, SEEK_SET) != 0) - return; - remain = za->cdir->size; - - while (remain > 0) { - n = remain > BUFSIZE ? BUFSIZE : remain; - if ((n=fread(buf, 1, n, za->zp)) <= 0) + if (_zip_filerange_crc(za->zp, za->cdir->offset, za->cdir->size, + &crc_got, NULL) < 0) return; - crc_got = crc32(crc_got, buf, n); - - remain -= n; - } - if (crc_got == crc_should) za->flags |= ZIP_AFL_TORRENT; } |