VeraCrypt
aboutsummaryrefslogtreecommitdiff
path: root/src/Common/libzip/zip_io_util.c
diff options
context:
space:
mode:
authorDLL125 <134442578+DLL125@users.noreply.github.com>2023-07-17 14:11:12 +0200
committerGitHub <noreply@github.com>2023-07-17 14:11:12 +0200
commit65765798d85258c0358b28b90aac68ed1851f49b (patch)
tree22f573edc4e16790d9be208fce95db1134fe2ba4 /src/Common/libzip/zip_io_util.c
parent6267b91931af87db2b95172389a6fbaac206e42e (diff)
downloadVeraCrypt-65765798d85258c0358b28b90aac68ed1851f49b.tar.gz
VeraCrypt-65765798d85258c0358b28b90aac68ed1851f49b.zip
Libzip (#1152)
* Update LZMA to latest * Update Libzip Libzip updated to latest.
Diffstat (limited to 'src/Common/libzip/zip_io_util.c')
-rw-r--r--src/Common/libzip/zip_io_util.c18
1 files changed, 15 insertions, 3 deletions
diff --git a/src/Common/libzip/zip_io_util.c b/src/Common/libzip/zip_io_util.c
index 0a1e4d5f..9fcd10b4 100644
--- a/src/Common/libzip/zip_io_util.c
+++ b/src/Common/libzip/zip_io_util.c
@@ -31,8 +31,10 @@
IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+#include <limits.h>
#include <stdlib.h>
#include <string.h>
+#include <zlib.h>
#include "zipint.h"
@@ -46,7 +48,7 @@ _zip_read(zip_source_t *src, zip_uint8_t *b, zip_uint64_t length, zip_error_t *e
}
if ((n = zip_source_read(src, b, length)) < 0) {
- _zip_error_set_from_source(error, src);
+ zip_error_set_from_source(error, src);
return -1;
}
@@ -81,7 +83,7 @@ _zip_read_data(zip_buffer_t *buffer, zip_source_t *src, size_t length, bool nulp
free(r);
return NULL;
}
- memcpy(r, data, length);
+ (void)memcpy_s(r, length, data, length);
}
else {
if (_zip_read(src, r, length, error) < 0) {
@@ -122,7 +124,7 @@ _zip_write(zip_t *za, const void *data, zip_uint64_t length) {
zip_int64_t n;
if ((n = zip_source_write(za->src, data, length)) < 0) {
- _zip_error_set_from_source(&za->error, za->src);
+ zip_error_set_from_source(&za->error, za->src);
return -1;
}
if ((zip_uint64_t)n != length) {
@@ -130,5 +132,15 @@ _zip_write(zip_t *za, const void *data, zip_uint64_t length) {
return -1;
}
+ if (za->write_crc != NULL) {
+ zip_uint64_t position = 0;
+ while (position < length) {
+ zip_uint64_t nn = ZIP_MIN(UINT_MAX, length - position);
+
+ *za->write_crc = (zip_uint32_t)crc32(*za->write_crc, (const Bytef *)data + position, (uInt)nn);
+ position += nn;
+ }
+ }
+
return 0;
}