summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--updater/zbin/minizip/ioapi.c21
-rw-r--r--updater/zbin/minizip/ioapi_mem.c68
-rw-r--r--updater/zbin/minizip/unzip.c10
3 files changed, 79 insertions, 20 deletions
diff --git a/updater/zbin/minizip/ioapi.c b/updater/zbin/minizip/ioapi.c
index c3f75ce..0916ffa 100644
--- a/updater/zbin/minizip/ioapi.c
+++ b/updater/zbin/minizip/ioapi.c
@@ -32,11 +32,22 @@ long call_zseek64 (const zlib_filefunc64_32_def* pfilefunc,voidpf filestream, ZP
return (*(pfilefunc->zfile_func64.zseek64_file)) (pfilefunc->zfile_func64.opaque,filestream,offset,origin);
else
{
- uLong offsetTruncated = (uLong)offset;
- if (offsetTruncated != offset)
- return -1;
- else
- return (*(pfilefunc->zseek32_file))(pfilefunc->zfile_func64.opaque,filestream,offsetTruncated,origin);
+ if (origin == ZLIB_FILEFUNC_SEEK_SET)
+ {
+ uLong offsetTruncated = (uLong)offset;
+ if (offsetTruncated != offset)
+ return -1;
+ else
+ return (*(pfilefunc->zseek32_file))(pfilefunc->zfile_func64.opaque,filestream,offsetTruncated,origin);
+ }
+ else
+ {
+ long offsetTruncated = (long)(__int64)offset;
+ if (offsetTruncated != (__int64)offset)
+ return -1;
+ else
+ return (*(pfilefunc->zseek32_file))(pfilefunc->zfile_func64.opaque,filestream,offsetTruncated,origin);
+ }
}
}
diff --git a/updater/zbin/minizip/ioapi_mem.c b/updater/zbin/minizip/ioapi_mem.c
index 6f50c47..6ac1d16 100644
--- a/updater/zbin/minizip/ioapi_mem.c
+++ b/updater/zbin/minizip/ioapi_mem.c
@@ -45,7 +45,7 @@ uLong ZCALLBACK fwrite_mem_func OF((
const void* buf,
uLong size));
-long ZCALLBACK ftell_mem_func OF((
+uLong ZCALLBACK ftell_mem_func OF((
voidpf opaque,
voidpf stream));
@@ -66,9 +66,9 @@ int ZCALLBACK ferror_mem_func OF((
typedef struct ourmemory_s {
char *base; /* Base of the region of memory we're using */
- uLong size; /* Size of the region of memory we're using */
- uLong limit; /* Furthest we've written */
- uLong cur_offset; /* Current offset in the area */
+ size_t size; /* Size of the region of memory we're using */
+ size_t limit; /* Furthest we've written */
+ size_t cur_offset; /* Current offset in the area */
} ourmemory_t;
voidpf ZCALLBACK fopen_mem_func (opaque, filename, mode)
@@ -109,7 +109,7 @@ uLong ZCALLBACK fread_mem_func (opaque, stream, buf, size)
ourmemory_t *mem = (ourmemory_t *)stream;
if (size > mem->size - mem->cur_offset)
- size = mem->size - mem->cur_offset;
+ size = (uLong)(mem->size - mem->cur_offset);
memcpy(buf, mem->base + mem->cur_offset, size);
mem->cur_offset+=size;
@@ -127,7 +127,7 @@ uLong ZCALLBACK fwrite_mem_func (opaque, stream, buf, size)
ourmemory_t *mem = (ourmemory_t *)stream;
if (size > mem->size - mem->cur_offset)
- size = mem->size - mem->cur_offset;
+ size = (uLong)(mem->size - mem->cur_offset);
memcpy(mem->base + mem->cur_offset, buf, size);
mem->cur_offset+=size;
@@ -137,12 +137,19 @@ uLong ZCALLBACK fwrite_mem_func (opaque, stream, buf, size)
return size;
}
-long ZCALLBACK ftell_mem_func (opaque, stream)
+uLong ZCALLBACK ftell_mem_func (opaque, stream)
voidpf opaque;
voidpf stream;
{
ourmemory_t *mem = (ourmemory_t *)stream;
+ return (uLong)mem->cur_offset;
+}
+
+ZPOS64_T ZCALLBACK ftell64_mem_func (voidpf opaque, voidpf stream)
+{
+ ourmemory_t *mem = (ourmemory_t *)stream;
+
return mem->cur_offset;
}
@@ -153,14 +160,14 @@ long ZCALLBACK fseek_mem_func (opaque, stream, offset, origin)
int origin;
{
ourmemory_t *mem = (ourmemory_t *)stream;
- uLong new_pos;
+ size_t new_pos;
switch (origin)
{
case ZLIB_FILEFUNC_SEEK_CUR :
- new_pos = mem->cur_offset + offset;
+ new_pos = mem->cur_offset + (long)offset;
break;
case ZLIB_FILEFUNC_SEEK_END :
- new_pos = mem->limit + offset;
+ new_pos = mem->limit + (long)offset;
break;
case ZLIB_FILEFUNC_SEEK_SET :
new_pos = offset;
@@ -172,6 +179,34 @@ long ZCALLBACK fseek_mem_func (opaque, stream, offset, origin)
return 1; /* Failed to seek that far */
if (new_pos > mem->limit)
+ memset(mem->base + mem->limit, 0, (new_pos - mem->limit));
+
+ mem->cur_offset = new_pos;
+ return 0;
+}
+
+long ZCALLBACK fseek64_mem_func (voidpf opaque, voidpf stream, ZPOS64_T offset, int origin)
+{
+ ourmemory_t *mem = (ourmemory_t *)stream;
+ size_t new_pos;
+ switch (origin)
+ {
+ case ZLIB_FILEFUNC_SEEK_CUR :
+ new_pos = (size_t)(mem->cur_offset + (__int64)offset);
+ break;
+ case ZLIB_FILEFUNC_SEEK_END :
+ new_pos = (size_t)(mem->limit + (__int64)offset);
+ break;
+ case ZLIB_FILEFUNC_SEEK_SET :
+ new_pos = (size_t)offset;
+ break;
+ default: return -1;
+ }
+
+ if (new_pos > mem->size)
+ return 1; /* Failed to seek that far */
+
+ if (new_pos > mem->limit)
memset(mem->base + mem->limit, 0, new_pos - mem->limit);
mem->cur_offset = new_pos;
@@ -217,3 +252,16 @@ void fill_memory_filefunc (pzlib_filefunc_def)
pzlib_filefunc_def->zerror_file = ferror_mem_func;
pzlib_filefunc_def->opaque = NULL;
}
+
+void fill_memory_filefunc64 (pzlib_filefunc_def)
+ zlib_filefunc64_def* pzlib_filefunc_def;
+{
+ pzlib_filefunc_def->zopen64_file = fopen_mem_func;
+ pzlib_filefunc_def->zread_file = fread_mem_func;
+ pzlib_filefunc_def->zwrite_file = fwrite_mem_func;
+ pzlib_filefunc_def->ztell64_file = ftell64_mem_func;
+ pzlib_filefunc_def->zseek64_file = fseek64_mem_func;
+ pzlib_filefunc_def->zclose_file = fclose_mem_func;
+ pzlib_filefunc_def->zerror_file = ferror_mem_func;
+ pzlib_filefunc_def->opaque = NULL;
+}
diff --git a/updater/zbin/minizip/unzip.c b/updater/zbin/minizip/unzip.c
index fc956ab..44f9876 100644
--- a/updater/zbin/minizip/unzip.c
+++ b/updater/zbin/minizip/unzip.c
@@ -985,7 +985,7 @@ local int unz64local_GetCurrentFileInfoInternal (unzFile file,
// Read extrafield
if ((err==UNZ_OK) && (extraField!=NULL))
{
- ZPOS64_T uSizeRead, uPosRead;
+ ZPOS64_T uSizeRead ;
if (file_info.size_file_extra<extraFieldBufferSize)
uSizeRead = file_info.size_file_extra;
else
@@ -1003,11 +1003,11 @@ local int unz64local_GetCurrentFileInfoInternal (unzFile file,
if (ZREAD64(s->z_filefunc, s->filestream,extraField,(uLong)uSizeRead)!=uSizeRead)
err=UNZ_ERRNO;
- uPosRead = ZTELL64(s->z_filefunc, s->filestream);
- ZSEEK64(s->z_filefunc, s->filestream,uPosRead - uSizeRead,ZLIB_FILEFUNC_SEEK_SET);
+ lSeek += file_info.size_file_extra - (uLong)uSizeRead;
}
+ else
+ lSeek += file_info.size_file_extra;
- lSeek += file_info.size_file_extra;
if ((err==UNZ_OK) && (file_info.size_file_extra != 0))
{
@@ -1761,7 +1761,7 @@ extern int ZEXPORT unzReadCurrentFile (unzFile file, voidp buf, unsigned len)
pfile_in_zip_read_info->stream.avail_in = (uInt)uReadThis;
}
- if ((pfile_in_zip_read_info->compression_method==0) || (pfile_in_zip_read_info->raw))
+ if ((pfile_in_zip_read_info->compression_method==0) || (pfile_in_zip_read_info->raw))
{
uInt uDoCopy,i ;