diff options
author | DLL125 <134442578+DLL125@users.noreply.github.com> | 2023-09-24 10:18:54 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-09-24 10:18:54 +0200 |
commit | 2363506e099a8e55b6010f10f71ff8ea8e1c6dfc (patch) | |
tree | 3146efbbcc2cbcadd6e9d64463b5753c85c8dabe /src/Common/libzip/zip_source_file_common.c | |
parent | 937c5cd5cd57893e85601b472e7d6cfd5ffdc6ab (diff) | |
download | VeraCrypt-2363506e099a8e55b6010f10f71ff8ea8e1c6dfc.tar.gz VeraCrypt-2363506e099a8e55b6010f10f71ff8ea8e1c6dfc.zip |
Libzip 1.10.1 (#1209)
Updated to the latest version for the VeraCrypt 1.26.6 release.
Diffstat (limited to 'src/Common/libzip/zip_source_file_common.c')
-rw-r--r-- | src/Common/libzip/zip_source_file_common.c | 22 |
1 files changed, 16 insertions, 6 deletions
diff --git a/src/Common/libzip/zip_source_file_common.c b/src/Common/libzip/zip_source_file_common.c index a2a46a44..6c58320f 100644 --- a/src/Common/libzip/zip_source_file_common.c +++ b/src/Common/libzip/zip_source_file_common.c @@ -54,6 +54,7 @@ zip_source_file_common_new(const char *fname, void *file, zip_uint64_t start, zi zip_source_file_context_t *ctx; zip_source_t *zs; zip_source_file_stat_t sb; + zip_uint64_t length; if (ops == NULL) { zip_error_set(error, ZIP_ER_INVAL, 0); @@ -82,10 +83,17 @@ zip_source_file_common_new(const char *fname, void *file, zip_uint64_t start, zi } if (len < 0) { - len = 0; + if (len == -1) { + len = ZIP_LENGTH_TO_END; + } + // TODO: return ZIP_ER_INVAL if len != ZIP_LENGTH_UNCHECKED? + length = 0; + } + else { + length = (zip_uint64_t)len; } - if (start > ZIP_INT64_MAX || start + (zip_uint64_t)len < start) { + if (start > ZIP_INT64_MAX || start + length < start) { zip_error_set(error, ZIP_ER_INVAL, 0); return NULL; } @@ -107,7 +115,7 @@ zip_source_file_common_new(const char *fname, void *file, zip_uint64_t start, zi } ctx->f = file; ctx->start = start; - ctx->len = (zip_uint64_t)len; + ctx->len = length; if (st) { (void)memcpy_s(&ctx->st, sizeof(ctx->st), st, sizeof(*st)); ctx->st.name = NULL; @@ -169,9 +177,11 @@ zip_source_file_common_new(const char *fname, void *file, zip_uint64_t start, zi } if (ctx->len == 0) { - ctx->len = sb.size - ctx->start; - ctx->st.size = ctx->len; - ctx->st.valid |= ZIP_STAT_SIZE; + if (len != ZIP_LENGTH_UNCHECKED) { + ctx->len = sb.size - ctx->start; + ctx->st.size = ctx->len; + ctx->st.valid |= ZIP_STAT_SIZE; + } /* when using a partial file, don't allow writing */ if (ctx->fname && start == 0 && ops->write != NULL) { |