diff options
author | Denys Vlasenko | 2010-06-19 17:50:44 +0200 |
---|---|---|
committer | Denys Vlasenko | 2010-06-19 17:50:44 +0200 |
commit | 020465218ccff1195a47a890037db37d0395c9d9 (patch) | |
tree | 491ffc11553f9de9b91c890f82dc0668c44660e8 /archival | |
parent | e329089c62ed813e97344f8c61d7dc34221fd5ee (diff) | |
parent | 8cd9f343e74ca65f36c42a44e845716ba5411663 (diff) | |
download | busybox-020465218ccff1195a47a890037db37d0395c9d9.zip busybox-020465218ccff1195a47a890037db37d0395c9d9.tar.gz |
Merge branch 'master' of git+ssh://vda@busybox.net/var/lib/git/busybox
Diffstat (limited to 'archival')
-rw-r--r-- | archival/unzip.c | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/archival/unzip.c b/archival/unzip.c index 1d3291a..84081c0 100644 --- a/archival/unzip.c +++ b/archival/unzip.c @@ -150,23 +150,26 @@ enum { zip_fd = 3 }; #if ENABLE_DESKTOP + +#define PEEK_FROM_END 16384 + /* NB: does not preserve file position! */ static uint32_t find_cdf_offset(void) { - unsigned char buf[1024]; cde_header_t cde_header; unsigned char *p; off_t end; + unsigned char *buf = xzalloc(PEEK_FROM_END); end = xlseek(zip_fd, 0, SEEK_END); - end -= 1024; + end -= PEEK_FROM_END; if (end < 0) end = 0; xlseek(zip_fd, end, SEEK_SET); - full_read(zip_fd, buf, 1024); + full_read(zip_fd, buf, PEEK_FROM_END); p = buf; - while (p <= buf + 1024 - CDE_HEADER_LEN - 4) { + while (p <= buf + PEEK_FROM_END - CDE_HEADER_LEN - 4) { if (*p != 'P') { p++; continue; @@ -180,8 +183,10 @@ static uint32_t find_cdf_offset(void) /* we found CDE! */ memcpy(cde_header.raw, p + 1, CDE_HEADER_LEN); FIX_ENDIANNESS_CDE(cde_header); + free(buf); return cde_header.formatted.cdf_offset; } + //free(buf); bb_error_msg_and_die("can't find file table"); }; |