diff options
author | Mounir IDRASSI <mounir.idrassi@idrix.fr> | 2019-10-04 21:13:31 +0200 |
---|---|---|
committer | Mounir IDRASSI <mounir.idrassi@idrix.fr> | 2019-10-04 21:15:10 +0200 |
commit | b6babc688d3d49ca32c3dbadfb2a4e32e9a43cdd (patch) | |
tree | d22d379c0786c9f870432cedc40da3c4a9c879ed /src/Common/libzip/zip_source_window.c | |
parent | 9a895bedde8ded1edbb814edb22a7197931a0d5b (diff) | |
download | VeraCrypt-b6babc688d3d49ca32c3dbadfb2a4e32e9a43cdd.tar.gz VeraCrypt-b6babc688d3d49ca32c3dbadfb2a4e32e9a43cdd.zip |
Windows: Update libzip to version 1.5.2
Diffstat (limited to 'src/Common/libzip/zip_source_window.c')
-rw-r--r-- | src/Common/libzip/zip_source_window.c | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/src/Common/libzip/zip_source_window.c b/src/Common/libzip/zip_source_window.c index f4701a04..d9e90bff 100644 --- a/src/Common/libzip/zip_source_window.c +++ b/src/Common/libzip/zip_source_window.c @@ -1,6 +1,6 @@ /* zip_source_window.c -- return part of lower source - Copyright (C) 2012-2017 Dieter Baron and Thomas Klausner + Copyright (C) 2012-2018 Dieter Baron and Thomas Klausner This file is part of libzip, a library to manipulate ZIP archives. The authors can be contacted at <libzip@nih.at> @@ -121,7 +121,6 @@ window_read(zip_source_t *src, void *_ctx, void *data, zip_uint64_t len, zip_sou struct window *ctx; zip_int64_t ret; zip_uint64_t n, i; - char b[8192]; ctx = (struct window *)_ctx; @@ -154,18 +153,30 @@ window_read(zip_source_t *src, void *_ctx, void *data, zip_uint64_t len, zip_sou } if (!ctx->needs_seek) { + DEFINE_BYTE_ARRAY(b, BUFSIZE); + + if (!byte_array_init(b, BUFSIZE)) { + zip_error_set(&ctx->error, ZIP_ER_MEMORY, 0); + return -1; + } + for (n = 0; n < ctx->start; n += (zip_uint64_t)ret) { - i = (ctx->start - n > sizeof(b) ? sizeof(b) : ctx->start - n); + i = (ctx->start - n > BUFSIZE ? BUFSIZE : ctx->start - n); if ((ret = zip_source_read(src, b, i)) < 0) { _zip_error_set_from_source(&ctx->error, src); + byte_array_fini(b); return -1; } if (ret == 0) { zip_error_set(&ctx->error, ZIP_ER_EOF, 0); + byte_array_fini(b); return -1; } } + + byte_array_fini(b); } + ctx->offset = ctx->start; return 0; |