diff options
Diffstat (limited to 'ext/zip/lib/zip_source_deflate.c')
-rw-r--r-- | ext/zip/lib/zip_source_deflate.c | 26 |
1 files changed, 12 insertions, 14 deletions
diff --git a/ext/zip/lib/zip_source_deflate.c b/ext/zip/lib/zip_source_deflate.c index 5d9c5e67bb..879953144c 100644 --- a/ext/zip/lib/zip_source_deflate.c +++ b/ext/zip/lib/zip_source_deflate.c @@ -60,14 +60,14 @@ static void deflate_free(struct deflate *); -ZIP_EXTERN(struct zip_source *) +struct zip_source * zip_source_deflate(struct zip *za, struct zip_source *src, - zip_uint16_t cm, int flags) + zip_int32_t cm, int flags) { struct deflate *ctx; struct zip_source *s2; - if (src == NULL || cm != ZIP_CM_DEFLATE) { + if (src == NULL || (cm != ZIP_CM_DEFLATE && !ZIP_CM_IS_DEFAULT(cm))) { _zip_error_set(&za->error, ZIP_ER_INVAL, 0); return NULL; } @@ -113,7 +113,7 @@ compress_read(struct zip_source *src, struct deflate *ctx, return 0; ctx->zstr.next_out = (Bytef *)data; - ctx->zstr.avail_out = len; + ctx->zstr.avail_out = (uInt)len; /* XXX: check for overflow */ end = 0; while (!end) { @@ -136,8 +136,7 @@ compress_read(struct zip_source *src, struct deflate *ctx, break; } - if ((n=zip_source_read(src, ctx->buffer, - sizeof(ctx->buffer))) < 0) { + if ((n=zip_source_read(src, ctx->buffer, sizeof(ctx->buffer))) < 0) { zip_source_error(src, ctx->e, ctx->e+1); end = 1; break; @@ -149,7 +148,7 @@ compress_read(struct zip_source *src, struct deflate *ctx, } else { ctx->zstr.next_in = (Bytef *)ctx->buffer; - ctx->zstr.avail_in = n; + ctx->zstr.avail_in = (uInt)n; } continue; } @@ -167,7 +166,7 @@ compress_read(struct zip_source *src, struct deflate *ctx, } if (ctx->zstr.avail_out < len) - return len - ctx->zstr.avail_out; + return (zip_int64_t)(len - ctx->zstr.avail_out); return (ctx->e[0] == 0) ? 0 : -1; } @@ -188,7 +187,7 @@ decompress_read(struct zip_source *src, struct deflate *ctx, return 0; ctx->zstr.next_out = (Bytef *)data; - ctx->zstr.avail_out = len; + ctx->zstr.avail_out = (uInt)len; /* XXX: check for overflow */ end = 0; while (!end && ctx->zstr.avail_out) { @@ -210,8 +209,7 @@ decompress_read(struct zip_source *src, struct deflate *ctx, break; } - if ((n=zip_source_read(src, ctx->buffer, - sizeof(ctx->buffer))) < 0) { + if ((n=zip_source_read(src, ctx->buffer, sizeof(ctx->buffer))) < 0) { zip_source_error(src, ctx->e, ctx->e+1); end = 1; break; @@ -220,7 +218,7 @@ decompress_read(struct zip_source *src, struct deflate *ctx, ctx->eof = 1; else { ctx->zstr.next_in = (Bytef *)ctx->buffer; - ctx->zstr.avail_in = n; + ctx->zstr.avail_in = (uInt)n; } continue; } @@ -237,7 +235,7 @@ decompress_read(struct zip_source *src, struct deflate *ctx, } if (ctx->zstr.avail_out < len) - return len - ctx->zstr.avail_out; + return (zip_int64_t)(len - ctx->zstr.avail_out); return (ctx->e[0] == 0) ? 0 : -1; } @@ -334,7 +332,7 @@ deflate_decompress(struct zip_source *src, void *ud, void *data, ctx->zstr.zfree = Z_NULL; ctx->zstr.opaque = NULL; ctx->zstr.next_in = (Bytef *)ctx->buffer; - ctx->zstr.avail_in = n; + ctx->zstr.avail_in = (uInt)n /* XXX: check for overflow */; /* negative value to tell zlib that there is no header */ if ((ret=inflateInit2(&ctx->zstr, -MAX_WBITS)) != Z_OK) { |