Windows: Update libzip to version 1.5.2

This commit is contained in:
Mounir IDRASSI 2019-10-04 21:13:31 +02:00
parent 9a895bedde
commit b6babc688d
No known key found for this signature in database
GPG Key ID: 02C30AE90FAE4A6F
112 changed files with 247 additions and 164 deletions

View File

@ -1,3 +1,11 @@
1.5.2 [2019-03-12]
==================
* Fix bug in AES encryption affecting certain file sizes
* Keep file permissions when modifying zip archives
* Support systems with small stack size.
* Support mbed TLS as crypto backend.
* Add nullability annotations.
1.5.1 [2018-04-11]
==================

View File

@ -3,7 +3,7 @@
/*
compat.h -- compatibility defines.
Copyright (C) 1999-2017 Dieter Baron and Thomas Klausner
Copyright (C) 1999-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>

View File

@ -76,7 +76,7 @@
#define HAVE_SHARED
/* END DEFINES */
#define PACKAGE "libzip"
#define VERSION "1.5.0a"
#define VERSION "1.5.2"
#ifndef HAVE_SSIZE_T_LIBZIP
# if SIZE_T_LIBZIP == INT_LIBZIP

View File

@ -3,7 +3,7 @@
/*
zip.h -- exported declarations.
Copyright (C) 1999-2017 Dieter Baron and Thomas Klausner
Copyright (C) 1999-2019 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>
@ -290,7 +290,7 @@ struct zip_error {
struct zip_stat {
zip_uint64_t valid; /* which fields have valid values */
const char *name; /* name of the file */
const char * name; /* name of the file */
zip_uint64_t index; /* index within archive */
zip_uint64_t size; /* size of file (uncompressed) */
zip_uint64_t comp_size; /* size of file (compressed) */
@ -302,7 +302,7 @@ struct zip_stat {
};
struct zip_buffer_fragment {
zip_uint8_t *data;
zip_uint8_t * data;
zip_uint64_t length;
};
@ -328,7 +328,7 @@ ZIP_EXTERN void zip_register_progress_callback(zip_t *, zip_progress_callback_t)
ZIP_EXTERN zip_int64_t zip_add(zip_t *, const char *, zip_source_t *); /* use zip_file_add */
ZIP_EXTERN zip_int64_t zip_add_dir(zip_t *, const char *); /* use zip_dir_add */
ZIP_EXTERN const char *zip_get_file_comment(zip_t *, zip_uint64_t, int *, int); /* use zip_file_get_comment */
ZIP_EXTERN const char * zip_get_file_comment(zip_t *, zip_uint64_t, int *, int); /* use zip_file_get_comment */
ZIP_EXTERN int zip_get_num_files(zip_t *); /* use zip_get_num_entries instead */
ZIP_EXTERN int zip_rename(zip_t *, zip_uint64_t, const char *); /* use zip_file_rename */
ZIP_EXTERN int zip_replace(zip_t *, zip_uint64_t, zip_source_t *); /* use zip_file_replace */
@ -344,7 +344,7 @@ ZIP_EXTERN int zip_delete(zip_t *, zip_uint64_t);
ZIP_EXTERN zip_int64_t zip_dir_add(zip_t *, const char *, zip_flags_t);
ZIP_EXTERN void zip_discard(zip_t *);
ZIP_EXTERN zip_error_t *zip_get_error(zip_t *);
ZIP_EXTERN zip_error_t * zip_get_error(zip_t *);
ZIP_EXTERN void zip_error_clear(zip_t *);
ZIP_EXTERN int zip_error_code_zip(const zip_error_t *);
ZIP_EXTERN int zip_error_code_system(const zip_error_t *);
@ -352,12 +352,12 @@ ZIP_EXTERN void zip_error_fini(zip_error_t *);
ZIP_EXTERN void zip_error_init(zip_error_t *);
ZIP_EXTERN void zip_error_init_with_code(zip_error_t *, int);
ZIP_EXTERN void zip_error_set(zip_error_t *, int, int);
ZIP_EXTERN const char *zip_error_strerror(zip_error_t *);
ZIP_EXTERN const char * zip_error_strerror(zip_error_t *);
ZIP_EXTERN int zip_error_system_type(const zip_error_t *);
ZIP_EXTERN zip_int64_t zip_error_to_data(const zip_error_t *, void *, zip_uint64_t);
ZIP_EXTERN int zip_fclose(zip_file_t *);
ZIP_EXTERN zip_t *zip_fdopen(int, int, int *);
ZIP_EXTERN zip_t * zip_fdopen(int, int, int *);
ZIP_EXTERN zip_int64_t zip_file_add(zip_t *, const char *, zip_source_t *, zip_flags_t);
ZIP_EXTERN void zip_file_error_clear(zip_file_t *);
ZIP_EXTERN int zip_file_extra_field_delete(zip_t *, zip_uint64_t, zip_uint16_t, zip_flags_t);
@ -365,10 +365,10 @@ ZIP_EXTERN int zip_file_extra_field_delete_by_id(zip_t *, zip_uint64_t, zip_uint
ZIP_EXTERN int zip_file_extra_field_set(zip_t *, zip_uint64_t, zip_uint16_t, zip_uint16_t, const zip_uint8_t *, zip_uint16_t, zip_flags_t);
ZIP_EXTERN zip_int16_t zip_file_extra_fields_count(zip_t *, zip_uint64_t, zip_flags_t);
ZIP_EXTERN zip_int16_t zip_file_extra_fields_count_by_id(zip_t *, zip_uint64_t, zip_uint16_t, zip_flags_t);
ZIP_EXTERN const zip_uint8_t *zip_file_extra_field_get(zip_t *, zip_uint64_t, zip_uint16_t, zip_uint16_t *, zip_uint16_t *, zip_flags_t);
ZIP_EXTERN const zip_uint8_t *zip_file_extra_field_get_by_id(zip_t *, zip_uint64_t, zip_uint16_t, zip_uint16_t, zip_uint16_t *, zip_flags_t);
ZIP_EXTERN const char *zip_file_get_comment(zip_t *, zip_uint64_t, zip_uint32_t *, zip_flags_t);
ZIP_EXTERN zip_error_t *zip_file_get_error(zip_file_t *);
ZIP_EXTERN const zip_uint8_t * zip_file_extra_field_get(zip_t *, zip_uint64_t, zip_uint16_t, zip_uint16_t *, zip_uint16_t *, zip_flags_t);
ZIP_EXTERN const zip_uint8_t * zip_file_extra_field_get_by_id(zip_t *, zip_uint64_t, zip_uint16_t, zip_uint16_t, zip_uint16_t *, zip_flags_t);
ZIP_EXTERN const char * zip_file_get_comment(zip_t *, zip_uint64_t, zip_uint32_t *, zip_flags_t);
ZIP_EXTERN zip_error_t * zip_file_get_error(zip_file_t *);
ZIP_EXTERN int zip_file_get_external_attributes(zip_t *, zip_uint64_t, zip_flags_t, zip_uint8_t *, zip_uint32_t *);
ZIP_EXTERN int zip_file_rename(zip_t *, zip_uint64_t, const char *, zip_flags_t);
ZIP_EXTERN int zip_file_replace(zip_t *, zip_uint64_t, zip_source_t *, zip_flags_t);
@ -376,22 +376,22 @@ ZIP_EXTERN int zip_file_set_comment(zip_t *, zip_uint64_t, const char *, zip_uin
ZIP_EXTERN int zip_file_set_encryption(zip_t *, zip_uint64_t, zip_uint16_t, const char *);
ZIP_EXTERN int zip_file_set_external_attributes(zip_t *, zip_uint64_t, zip_flags_t, zip_uint8_t, zip_uint32_t);
ZIP_EXTERN int zip_file_set_mtime(zip_t *, zip_uint64_t, time_t, zip_flags_t);
ZIP_EXTERN const char *zip_file_strerror(zip_file_t *);
ZIP_EXTERN zip_file_t *zip_fopen(zip_t *, const char *, zip_flags_t);
ZIP_EXTERN zip_file_t *zip_fopen_encrypted(zip_t *, const char *, zip_flags_t, const char *);
ZIP_EXTERN zip_file_t *zip_fopen_index(zip_t *, zip_uint64_t, zip_flags_t);
ZIP_EXTERN zip_file_t *zip_fopen_index_encrypted(zip_t *, zip_uint64_t, zip_flags_t, const char *);
ZIP_EXTERN const char * zip_file_strerror(zip_file_t *);
ZIP_EXTERN zip_file_t * zip_fopen(zip_t *, const char *, zip_flags_t);
ZIP_EXTERN zip_file_t * zip_fopen_encrypted(zip_t *, const char *, zip_flags_t, const char *);
ZIP_EXTERN zip_file_t * zip_fopen_index(zip_t *, zip_uint64_t, zip_flags_t);
ZIP_EXTERN zip_file_t * zip_fopen_index_encrypted(zip_t *, zip_uint64_t, zip_flags_t, const char *);
ZIP_EXTERN zip_int64_t zip_fread(zip_file_t *, void *, zip_uint64_t);
ZIP_EXTERN zip_int8_t zip_fseek(zip_file_t *, zip_int64_t, int);
ZIP_EXTERN zip_int64_t zip_ftell(zip_file_t *);
ZIP_EXTERN const char *zip_get_archive_comment(zip_t *, int *, zip_flags_t);
ZIP_EXTERN const char * zip_get_archive_comment(zip_t *, int *, zip_flags_t);
ZIP_EXTERN int zip_get_archive_flag(zip_t *, zip_flags_t, zip_flags_t);
ZIP_EXTERN const char *zip_get_name(zip_t *, zip_uint64_t, zip_flags_t);
ZIP_EXTERN const char * zip_get_name(zip_t *, zip_uint64_t, zip_flags_t);
ZIP_EXTERN zip_int64_t zip_get_num_entries(zip_t *, zip_flags_t);
ZIP_EXTERN const char *zip_libzip_version(void);
ZIP_EXTERN const char * zip_libzip_version(void);
ZIP_EXTERN zip_int64_t zip_name_locate(zip_t *, const char *, zip_flags_t);
ZIP_EXTERN zip_t *zip_open(const char *, int, int *);
ZIP_EXTERN zip_t *zip_open_from_source(zip_source_t *, int, zip_error_t *);
ZIP_EXTERN zip_t * zip_open(const char *, int, int *);
ZIP_EXTERN zip_t * zip_open_from_source(zip_source_t *, int, zip_error_t *);
ZIP_EXTERN int zip_register_progress_callback_with_state(zip_t *, double, zip_progress_callback, void (*)(void *), void *);
ZIP_EXTERN int zip_set_archive_comment(zip_t *, const char *, zip_uint16_t);
ZIP_EXTERN int zip_set_archive_flag(zip_t *, zip_flags_t, int);
@ -399,20 +399,20 @@ ZIP_EXTERN int zip_set_default_password(zip_t *, const char *);
ZIP_EXTERN int zip_set_file_compression(zip_t *, zip_uint64_t, zip_int32_t, zip_uint32_t);
ZIP_EXTERN int zip_source_begin_write(zip_source_t *);
ZIP_EXTERN int zip_source_begin_write_cloning(zip_source_t *, zip_uint64_t);
ZIP_EXTERN zip_source_t *zip_source_buffer(zip_t *, const void *, zip_uint64_t, int);
ZIP_EXTERN zip_source_t *zip_source_buffer_create(const void *, zip_uint64_t, int, zip_error_t *);
ZIP_EXTERN zip_source_t *zip_source_buffer_fragment(zip_t *, const zip_buffer_fragment_t *, zip_uint64_t, int);
ZIP_EXTERN zip_source_t *zip_source_buffer_fragment_create(const zip_buffer_fragment_t *, zip_uint64_t, int, zip_error_t *);
ZIP_EXTERN zip_source_t * zip_source_buffer(zip_t *, const void *, zip_uint64_t, int);
ZIP_EXTERN zip_source_t * zip_source_buffer_create(const void *, zip_uint64_t, int, zip_error_t *);
ZIP_EXTERN zip_source_t * zip_source_buffer_fragment(zip_t *, const zip_buffer_fragment_t *, zip_uint64_t, int);
ZIP_EXTERN zip_source_t * zip_source_buffer_fragment_create(const zip_buffer_fragment_t *, zip_uint64_t, int, zip_error_t *);
ZIP_EXTERN int zip_source_close(zip_source_t *);
ZIP_EXTERN int zip_source_commit_write(zip_source_t *);
ZIP_EXTERN zip_error_t *zip_source_error(zip_source_t *);
ZIP_EXTERN zip_source_t *zip_source_file(zip_t *, const char *, zip_uint64_t, zip_int64_t);
ZIP_EXTERN zip_source_t *zip_source_file_create(const char *, zip_uint64_t, zip_int64_t, zip_error_t *);
ZIP_EXTERN zip_source_t *zip_source_filep(zip_t *, FILE *, zip_uint64_t, zip_int64_t);
ZIP_EXTERN zip_source_t *zip_source_filep_create(FILE *, zip_uint64_t, zip_int64_t, zip_error_t *);
ZIP_EXTERN zip_error_t * zip_source_error(zip_source_t *);
ZIP_EXTERN zip_source_t * zip_source_file(zip_t *, const char *, zip_uint64_t, zip_int64_t);
ZIP_EXTERN zip_source_t * zip_source_file_create(const char *, zip_uint64_t, zip_int64_t, zip_error_t *);
ZIP_EXTERN zip_source_t * zip_source_filep(zip_t *, FILE *, zip_uint64_t, zip_int64_t);
ZIP_EXTERN zip_source_t * zip_source_filep_create(FILE *, zip_uint64_t, zip_int64_t, zip_error_t *);
ZIP_EXTERN void zip_source_free(zip_source_t *);
ZIP_EXTERN zip_source_t *zip_source_function(zip_t *, zip_source_callback, void *);
ZIP_EXTERN zip_source_t *zip_source_function_create(zip_source_callback, void *, zip_error_t *);
ZIP_EXTERN zip_source_t * zip_source_function(zip_t *, zip_source_callback , void *);
ZIP_EXTERN zip_source_t * zip_source_function_create(zip_source_callback , void *, zip_error_t *);
ZIP_EXTERN int zip_source_is_deleted(zip_source_t *);
ZIP_EXTERN void zip_source_keep(zip_source_t *);
ZIP_EXTERN zip_int64_t zip_source_make_command_bitmap(zip_source_cmd_t, ...);
@ -434,11 +434,11 @@ ZIP_EXTERN zip_source_t *zip_source_win32w(zip_t *, const wchar_t *, zip_uint64_
ZIP_EXTERN zip_source_t *zip_source_win32w_create(const wchar_t *, zip_uint64_t, zip_int64_t, zip_error_t *);
#endif
ZIP_EXTERN zip_int64_t zip_source_write(zip_source_t *, const void *, zip_uint64_t);
ZIP_EXTERN zip_source_t *zip_source_zip(zip_t *, zip_t *, zip_uint64_t, zip_flags_t, zip_uint64_t, zip_int64_t);
ZIP_EXTERN zip_source_t * zip_source_zip(zip_t *, zip_t *, zip_uint64_t, zip_flags_t, zip_uint64_t, zip_int64_t);
ZIP_EXTERN int zip_stat(zip_t *, const char *, zip_flags_t, zip_stat_t *);
ZIP_EXTERN int zip_stat_index(zip_t *, zip_uint64_t, zip_flags_t, zip_stat_t *);
ZIP_EXTERN void zip_stat_init(zip_stat_t *);
ZIP_EXTERN const char *zip_strerror(zip_t *);
ZIP_EXTERN void zip_stat_init( zip_stat_t *);
ZIP_EXTERN const char * zip_strerror(zip_t *);
ZIP_EXTERN int zip_unchange(zip_t *, zip_uint64_t);
ZIP_EXTERN int zip_unchange_all(zip_t *);
ZIP_EXTERN int zip_unchange_archive(zip_t *);

View File

@ -1,6 +1,6 @@
/*
zip_add.c -- add file via callback function
Copyright (C) 1999-2014 Dieter Baron and Thomas Klausner
Copyright (C) 1999-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>

View File

@ -1,6 +1,6 @@
/*
zip_add_dir.c -- add directory
Copyright (C) 1999-2014 Dieter Baron and Thomas Klausner
Copyright (C) 1999-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>

View File

@ -1,6 +1,6 @@
/*
zip_add_entry.c -- create and init struct zip_entry
Copyright (C) 1999-2016 Dieter Baron and Thomas Klausner
Copyright (C) 1999-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>

View File

@ -1,6 +1,6 @@
/*
zip_algorithm_deflate.c -- deflate (de)compression routines
Copyright (C) 2017 Dieter Baron and Thomas Klausner
Copyright (C) 2017-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>

View File

@ -1,6 +1,6 @@
/*
zip_buffer.c -- bounds checked access to memory buffer
Copyright (C) 2014-2016 Dieter Baron and Thomas Klausner
Copyright (C) 2014-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>

View File

@ -1,6 +1,6 @@
/*
zip_close.c -- close zip archive and update changes
Copyright (C) 1999-2017 Dieter Baron and Thomas Klausner
Copyright (C) 1999-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>
@ -520,17 +520,24 @@ add_data(zip_t *za, zip_source_t *src, zip_dirent_t *de) {
static int
copy_data(zip_t *za, zip_uint64_t len) {
zip_uint8_t buf[BUFSIZE];
DEFINE_BYTE_ARRAY(buf, BUFSIZE);
size_t n;
double total = (double)len;
if (!byte_array_init(buf, BUFSIZE)) {
zip_error_set(&za->error, ZIP_ER_MEMORY, 0);
return -1;
}
while (len > 0) {
n = len > sizeof(buf) ? sizeof(buf) : len;
n = len > BUFSIZE ? BUFSIZE : len;
if (_zip_read(za->src, buf, n, &za->error) < 0) {
byte_array_fini(buf);
return -1;
}
if (_zip_write(za, buf, n) < 0) {
byte_array_fini(buf);
return -1;
}
@ -539,13 +546,14 @@ copy_data(zip_t *za, zip_uint64_t len) {
_zip_progress_update(za->progress, (total - (double)len) / total);
}
byte_array_fini(buf);
return 0;
}
static int
copy_source(zip_t *za, zip_source_t *src, zip_int64_t data_length) {
zip_uint8_t buf[BUFSIZE];
DEFINE_BYTE_ARRAY(buf, BUFSIZE);
zip_int64_t n, current;
int ret;
@ -554,14 +562,19 @@ copy_source(zip_t *za, zip_source_t *src, zip_int64_t data_length) {
return -1;
}
if (!byte_array_init(buf, BUFSIZE)) {
zip_error_set(&za->error, ZIP_ER_MEMORY, 0);
return -1;
}
ret = 0;
current = 0;
while ((n = zip_source_read(src, buf, sizeof(buf))) > 0) {
while ((n = zip_source_read(src, buf, BUFSIZE)) > 0) {
if (_zip_write(za, buf, (zip_uint64_t)n) < 0) {
ret = -1;
break;
}
if (n == sizeof(buf) && za->progress && data_length > 0) {
if (n == BUFSIZE && za->progress && data_length > 0) {
current += n;
_zip_progress_update(za->progress, (double)current / (double)data_length);
}
@ -572,6 +585,8 @@ copy_source(zip_t *za, zip_source_t *src, zip_int64_t data_length) {
ret = -1;
}
byte_array_fini(buf);
zip_source_close(src);
return ret;

View File

@ -1,6 +1,6 @@
/*
zip_delete.c -- delete file from zip archive
Copyright (C) 1999-2016 Dieter Baron and Thomas Klausner
Copyright (C) 1999-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>

View File

@ -1,6 +1,6 @@
/*
zip_dir_add.c -- add directory
Copyright (C) 1999-2014 Dieter Baron and Thomas Klausner
Copyright (C) 1999-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>

View File

@ -1,6 +1,6 @@
/*
zip_dirent.c -- read directory entry (local or central), clean dirent
Copyright (C) 1999-2017 Dieter Baron and Thomas Klausner
Copyright (C) 1999-2019 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>
@ -1069,6 +1069,12 @@ _zip_u2d_time(time_t intime, zip_uint16_t *dtime, zip_uint16_t *ddate) {
struct tm *tm;
tm = localtime(&intime);
if (tm == NULL) {
/* if localtime() fails, return an arbitrary date (1980-01-01 00:00:00) */
*ddate = (1 << 5) + 1;
*dtime = 0;
return;
}
if (tm->tm_year < 80) {
tm->tm_year = 80;
}

View File

@ -1,6 +1,6 @@
/*
zip_discard.c -- discard and free struct zip
Copyright (C) 1999-2017 Dieter Baron and Thomas Klausner
Copyright (C) 1999-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>

View File

@ -1,6 +1,6 @@
/*
zip_entry.c -- struct zip_entry helper functions
Copyright (C) 1999-2014 Dieter Baron and Thomas Klausner
Copyright (C) 1999-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>

View File

@ -1,6 +1,6 @@
/*
zip_error.c -- zip_error_t helper functions
Copyright (C) 1999-2016 Dieter Baron and Thomas Klausner
Copyright (C) 1999-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>

View File

@ -1,6 +1,6 @@
/*
zip_error_clear.c -- clear zip error
Copyright (C) 1999-2014 Dieter Baron and Thomas Klausner
Copyright (C) 1999-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>

View File

@ -1,6 +1,6 @@
/*
zip_error_get.c -- get zip error
Copyright (C) 1999-2014 Dieter Baron and Thomas Klausner
Copyright (C) 1999-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>

View File

@ -1,6 +1,6 @@
/*
zip_error_get_sys_type.c -- return type of system error code
Copyright (C) 1999-2014 Dieter Baron and Thomas Klausner
Copyright (C) 1999-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>

View File

@ -1,6 +1,6 @@
/*
zip_error_sterror.c -- get string representation of struct zip_error
Copyright (C) 1999-2016 Dieter Baron and Thomas Klausner
Copyright (C) 1999-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>

View File

@ -1,6 +1,6 @@
/*
zip_error_to_str.c -- get string representation of zip error code
Copyright (C) 1999-2016 Dieter Baron and Thomas Klausner
Copyright (C) 1999-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>

View File

@ -1,6 +1,6 @@
/*
zip_extra_field.c -- manipulate extra fields
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>

View File

@ -1,6 +1,6 @@
/*
zip_extra_field_api.c -- public extra fields API functions
Copyright (C) 2012-2014 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>

View File

@ -1,6 +1,6 @@
/*
zip_fclose.c -- close file in zip archive
Copyright (C) 1999-2014 Dieter Baron and Thomas Klausner
Copyright (C) 1999-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>

View File

@ -1,6 +1,6 @@
/*
zip_fdopen.c -- open read-only archive from file descriptor
Copyright (C) 2009-2017 Dieter Baron and Thomas Klausner
Copyright (C) 2009-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>
@ -67,12 +67,14 @@ zip_fdopen(int fd_orig, int _flags, int *zep) {
zip_error_init(&error);
if ((src = zip_source_filep_create(fp, 0, -1, &error)) == NULL) {
fclose(fp);
_zip_set_open_error(zep, &error, 0);
zip_error_fini(&error);
return NULL;
}
if ((za = zip_open_from_source(src, _flags, &error)) == NULL) {
zip_source_free(src);
_zip_set_open_error(zep, &error, 0);
zip_error_fini(&error);
return NULL;

View File

@ -1,6 +1,6 @@
/*
zip_file_add.c -- add file via callback function
Copyright (C) 1999-2014 Dieter Baron and Thomas Klausner
Copyright (C) 1999-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>

View File

@ -1,6 +1,6 @@
/*
zip_file_error_clear.c -- clear zip file error
Copyright (C) 1999-2014 Dieter Baron and Thomas Klausner
Copyright (C) 1999-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>

View File

@ -1,6 +1,6 @@
/*
zip_file_error_get.c -- get zip file error
Copyright (C) 1999-2014 Dieter Baron and Thomas Klausner
Copyright (C) 1999-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>

View File

@ -1,6 +1,6 @@
/*
zip_file_get_comment.c -- get file comment
Copyright (C) 2006-2014 Dieter Baron and Thomas Klausner
Copyright (C) 2006-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>

View File

@ -1,6 +1,6 @@
/*
zip_file_get_external_attributes.c -- get opsys/external attributes
Copyright (C) 2013-2014 Dieter Baron and Thomas Klausner
Copyright (C) 2013-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>

View File

@ -1,6 +1,6 @@
/*
zip_file_get_offset.c -- get offset of file data in archive.
Copyright (C) 1999-2017 Dieter Baron and Thomas Klausner
Copyright (C) 1999-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>

View File

@ -1,6 +1,6 @@
/*
zip_file_rename.c -- rename file in zip archive
Copyright (C) 1999-2014 Dieter Baron and Thomas Klausner
Copyright (C) 1999-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>

View File

@ -1,6 +1,6 @@
/*
zip_file_replace.c -- replace file via callback function
Copyright (C) 1999-2014 Dieter Baron and Thomas Klausner
Copyright (C) 1999-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>

View File

@ -1,6 +1,6 @@
/*
zip_file_set_comment.c -- set comment for file in archive
Copyright (C) 2006-2014 Dieter Baron and Thomas Klausner
Copyright (C) 2006-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>

View File

@ -1,6 +1,6 @@
/*
zip_file_set_external_attributes.c -- set external attributes for entry
Copyright (C) 2013-2014 Dieter Baron and Thomas Klausner
Copyright (C) 2013-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>

View File

@ -1,6 +1,6 @@
/*
zip_file_set_mtime.c -- set modification time of entry.
Copyright (C) 2014 Dieter Baron and Thomas Klausner
Copyright (C) 2014-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>

View File

@ -1,6 +1,6 @@
/*
zip_file_sterror.c -- get string representation of zip file error
Copyright (C) 1999-2014 Dieter Baron and Thomas Klausner
Copyright (C) 1999-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>

View File

@ -1,6 +1,6 @@
/*
zip_filerange_crc.c -- compute CRC32 for a range of a file
Copyright (C) 2008-2016 Dieter Baron and Thomas Klausner
Copyright (C) 2008-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>
@ -39,7 +39,8 @@
int
_zip_filerange_crc(zip_source_t *src, zip_uint64_t start, zip_uint64_t len, uLong *crcp, zip_error_t *error) {
Bytef buf[BUFSIZE];
DEFINE_BYTE_ARRAY(buf, BUFSIZE);
zip_int64_t n;
*crcp = crc32(0L, Z_NULL, 0);
@ -54,14 +55,21 @@ _zip_filerange_crc(zip_source_t *src, zip_uint64_t start, zip_uint64_t len, uLon
return -1;
}
if (!byte_array_init(buf, BUFSIZE)) {
zip_error_set(error, ZIP_ER_MEMORY, 0);
return -1;
}
while (len > 0) {
n = (zip_int64_t)(len > BUFSIZE ? BUFSIZE : len);
if ((n = zip_source_read(src, buf, (zip_uint64_t)n)) < 0) {
_zip_error_set_from_source(error, src);
byte_array_fini(buf);
return -1;
}
if (n == 0) {
zip_error_set(error, ZIP_ER_EOF, 0);
byte_array_fini(buf);
return -1;
}
@ -70,5 +78,7 @@ _zip_filerange_crc(zip_source_t *src, zip_uint64_t start, zip_uint64_t len, uLon
len -= (zip_uint64_t)n;
}
byte_array_fini(buf);
return 0;
}

View File

@ -1,6 +1,6 @@
/*
zip_fopen.c -- open file in zip archive for reading
Copyright (C) 1999-2014 Dieter Baron and Thomas Klausner
Copyright (C) 1999-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>

View File

@ -1,6 +1,6 @@
/*
zip_fopen_encrypted.c -- open file for reading with password
Copyright (C) 1999-2014 Dieter Baron and Thomas Klausner
Copyright (C) 1999-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>

View File

@ -1,6 +1,6 @@
/*
zip_fopen_index.c -- open file in zip archive for reading by index
Copyright (C) 1999-2016 Dieter Baron and Thomas Klausner
Copyright (C) 1999-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>

View File

@ -1,6 +1,6 @@
/*
zip_fopen_index_encrypted.c -- open file for reading by index w/ password
Copyright (C) 1999-2016 Dieter Baron and Thomas Klausner
Copyright (C) 1999-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>

View File

@ -1,6 +1,6 @@
/*
zip_fread.c -- read from file
Copyright (C) 1999-2014 Dieter Baron and Thomas Klausner
Copyright (C) 1999-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>

View File

@ -1,6 +1,6 @@
/*
zip_get_archive_comment.c -- get archive comment
Copyright (C) 2006-2014 Dieter Baron and Thomas Klausner
Copyright (C) 2006-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>

View File

@ -1,6 +1,6 @@
/*
zip_get_archive_flag.c -- get archive global flag
Copyright (C) 2008-2014 Dieter Baron and Thomas Klausner
Copyright (C) 2008-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>

View File

@ -1,6 +1,6 @@
/*
zip_get_encryption_implementation.c -- get encryption implementation
Copyright (C) 2009-2016 Dieter Baron and Thomas Klausner
Copyright (C) 2009-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>

View File

@ -1,6 +1,6 @@
/*
zip_get_file_comment.c -- get file comment
Copyright (C) 2006-2014 Dieter Baron and Thomas Klausner
Copyright (C) 2006-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>

View File

@ -1,6 +1,6 @@
/*
zip_get_name.c -- get filename for a file in zip file
Copyright (C) 1999-2014 Dieter Baron and Thomas Klausner
Copyright (C) 1999-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>

View File

@ -1,6 +1,6 @@
/*
zip_get_num_entries.c -- get number of entries in archive
Copyright (C) 1999-2014 Dieter Baron and Thomas Klausner
Copyright (C) 1999-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>

View File

@ -1,6 +1,6 @@
/*
zip_get_num_files.c -- get number of files in archive
Copyright (C) 1999-2014 Dieter Baron and Thomas Klausner
Copyright (C) 1999-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>

View File

@ -1,6 +1,6 @@
/*
zip_hash.c -- hash table string -> uint64
Copyright (C) 2015-2017 Dieter Baron and Thomas Klausner
Copyright (C) 2015-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>

View File

@ -1,6 +1,6 @@
/*
zip_io_util.c -- I/O helper functions
Copyright (C) 1999-2016 Dieter Baron and Thomas Klausner
Copyright (C) 1999-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>

View File

@ -1,6 +1,6 @@
/*
zip_memdup.c -- internal zip function, "strdup" with len
Copyright (C) 1999-2014 Dieter Baron and Thomas Klausner
Copyright (C) 1999-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>

View File

@ -1,6 +1,6 @@
/*
zip_name_locate.c -- get index by name
Copyright (C) 1999-2016 Dieter Baron and Thomas Klausner
Copyright (C) 1999-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>

View File

@ -1,6 +1,6 @@
/*
zip_new.c -- create and init struct zip
Copyright (C) 1999-2017 Dieter Baron and Thomas Klausner
Copyright (C) 1999-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>

View File

@ -1,6 +1,6 @@
/*
zip_open.c -- open zip archive by name
Copyright (C) 1999-2017 Dieter Baron and Thomas Klausner
Copyright (C) 1999-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>
@ -177,7 +177,6 @@ _zip_open(zip_source_t *src, unsigned int flags, zip_error_t *error) {
/* treat empty files as empty archives */
if (len == 0) {
if ((za = _zip_allocate_new(src, flags, error)) == NULL) {
zip_source_free(src);
return NULL;
}

View File

@ -1,6 +1,6 @@
/*
zip_progress.c -- progress reporting
Copyright (C) 2017 Dieter Baron and Thomas Klausner
Copyright (C) 2017-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>

View File

@ -1,6 +1,6 @@
/*
zip_rename.c -- rename file in zip archive
Copyright (C) 1999-2014 Dieter Baron and Thomas Klausner
Copyright (C) 1999-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>

View File

@ -1,6 +1,6 @@
/*
zip_replace.c -- replace file via callback function
Copyright (C) 1999-2014 Dieter Baron and Thomas Klausner
Copyright (C) 1999-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>

View File

@ -1,6 +1,6 @@
/*
zip_set_archive_comment.c -- set archive comment
Copyright (C) 2006-2014 Dieter Baron and Thomas Klausner
Copyright (C) 2006-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>

View File

@ -1,6 +1,6 @@
/*
zip_get_archive_flag.c -- set archive global flag
Copyright (C) 2008-2014 Dieter Baron and Thomas Klausner
Copyright (C) 2008-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>

View File

@ -1,6 +1,6 @@
/*
zip_set_default_password.c -- set default password for decryption
Copyright (C) 2009-2016 Dieter Baron and Thomas Klausner
Copyright (C) 2009-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>

View File

@ -1,6 +1,6 @@
/*
zip_set_file_comment.c -- set comment for file in archive
Copyright (C) 2006-2014 Dieter Baron and Thomas Klausner
Copyright (C) 2006-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>

View File

@ -1,6 +1,6 @@
/*
zip_set_file_compression.c -- set compression for file in archive
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>

View File

@ -1,6 +1,6 @@
/*
zip_set_name.c -- rename helper function
Copyright (C) 1999-2016 Dieter Baron and Thomas Klausner
Copyright (C) 1999-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>

View File

@ -1,6 +1,6 @@
/*
zip_source_begin_write.c -- start a new file for writing
Copyright (C) 2014 Dieter Baron and Thomas Klausner
Copyright (C) 2014-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>

View File

@ -1,6 +1,6 @@
/*
zip_source_begin_write_cloning.c -- clone part of file for writing
Copyright (C) 2017 Dieter Baron and Thomas Klausner
Copyright (C) 2017-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>

View File

@ -1,6 +1,6 @@
/*
zip_source_buffer.c -- create zip data source from buffer
Copyright (C) 1999-2017 Dieter Baron and Thomas Klausner
Copyright (C) 1999-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>
@ -389,8 +389,8 @@ buffer_grow_fragments(buffer_t *buffer, zip_uint64_t capacity, zip_error_t *erro
}
if ((fragments = realloc(buffer->fragments, sizeof(buffer->fragments[0]) * capacity)) == NULL) {
zip_error_set(error, ZIP_ER_MEMORY, 0);
return false;
zip_error_set(error, ZIP_ER_MEMORY, 0);
return false;
}
buffer->fragments = fragments;
if ((offsets = realloc(buffer->fragment_offsets, sizeof(buffer->fragment_offsets[0]) * (capacity + 1))) == NULL) {

View File

@ -1,6 +1,6 @@
/*
zip_source_call.c -- invoke callback command on zip_source
Copyright (C) 2009-2014 Dieter Baron and Thomas Klausner
Copyright (C) 2009-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>

View File

@ -1,6 +1,6 @@
/*
zip_source_close.c -- close zip_source (stop reading)
Copyright (C) 2009-2014 Dieter Baron and Thomas Klausner
Copyright (C) 2009-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>

View File

@ -1,6 +1,6 @@
/*
zip_source_commit_write.c -- commit changes to file
Copyright (C) 2014 Dieter Baron and Thomas Klausner
Copyright (C) 2014-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>

View File

@ -1,6 +1,6 @@
/*
zip_source_compress.c -- (de)compression routines
Copyright (C) 2017 Dieter Baron and Thomas Klausner
Copyright (C) 2017-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>

View File

@ -1,6 +1,6 @@
/*
zip_source_crc.c -- pass-through source that calculates CRC32 and size
Copyright (C) 2009-2017 Dieter Baron and Thomas Klausner
Copyright (C) 2009-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>
@ -148,7 +148,6 @@ crc_read(zip_source_t *src, void *_ctx, void *data, zip_uint64_t len, zip_source
st->comp_method = ZIP_CM_STORE;
st->encryption_method = ZIP_EM_NONE;
st->valid |= ZIP_STAT_SIZE | ZIP_STAT_CRC | ZIP_STAT_COMP_SIZE | ZIP_STAT_COMP_METHOD | ZIP_STAT_ENCRYPTION_METHOD;
;
}
return 0;
}

View File

@ -1,6 +1,6 @@
/*
zip_source_error.c -- get last error from zip_source
Copyright (C) 2009-2016 Dieter Baron and Thomas Klausner
Copyright (C) 2009-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>

View File

@ -1,6 +1,6 @@
/*
zip_source_file.c -- create data source from file
Copyright (C) 1999-2016 Dieter Baron and Thomas Klausner
Copyright (C) 1999-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>

View File

@ -1,6 +1,6 @@
/*
zip_source_filep.c -- create data source from FILE *
Copyright (C) 1999-2017 Dieter Baron and Thomas Klausner
Copyright (C) 1999-2019 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>
@ -34,6 +34,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
#include <sys/stat.h>
#include "zipint.h"
@ -412,21 +413,27 @@ read_file(void *state, void *data, zip_uint64_t len, zip_source_cmd_t cmd) {
#endif
case ZIP_SOURCE_COMMIT_WRITE: {
mode_t mask;
mode_t mode;
struct stat st;
if (fclose(ctx->fout) < 0) {
ctx->fout = NULL;
zip_error_set(&ctx->error, ZIP_ER_WRITE, errno);
}
ctx->fout = NULL;
if (stat(ctx->fname, &st) == 0) {
mode = st.st_mode;
} else {
mode_t mask = umask(022);
umask(mask);
mode = 0666 & ~mask;
}
if (rename(ctx->tmpname, ctx->fname) < 0) {
zip_error_set(&ctx->error, ZIP_ER_RENAME, errno);
return -1;
}
mask = umask(022);
umask(mask);
/* not much we can do if chmod fails except make the whole commit fail */
(void)chmod(ctx->fname, 0666 & ~mask);
(void)chmod(ctx->fname, mode);
free(ctx->tmpname);
ctx->tmpname = NULL;
return 0;

View File

@ -1,6 +1,6 @@
/*
zip_source_free.c -- free zip data source
Copyright (C) 1999-2015 Dieter Baron and Thomas Klausner
Copyright (C) 1999-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>

View File

@ -1,6 +1,6 @@
/*
zip_source_function.c -- create zip data source from callback function
Copyright (C) 1999-2017 Dieter Baron and Thomas Klausner
Copyright (C) 1999-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>

View File

@ -1,6 +1,6 @@
/*
zip_source_get_compression_flags.c -- get compression flags for entry
Copyright (C) 2017 Dieter Baron and Thomas Klausner
Copyright (C) 2017-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>

View File

@ -1,6 +1,6 @@
/*
zip_source_is_deleted.c -- was archive was removed?
Copyright (C) 2014 Dieter Baron and Thomas Klausner
Copyright (C) 2014-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>

View File

@ -1,6 +1,6 @@
/*
zip_source_layered.c -- create layered source
Copyright (C) 2009-2014 Dieter Baron and Thomas Klausner
Copyright (C) 2009-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>

View File

@ -1,6 +1,6 @@
/*
zip_source_open.c -- open zip_source (prepare for reading)
Copyright (C) 2009-2017 Dieter Baron and Thomas Klausner
Copyright (C) 2009-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>

View File

@ -1,6 +1,6 @@
/*
zip_source_pkware.c -- Traditional PKWARE de/encryption routines
Copyright (C) 2009-2016 Dieter Baron and Thomas Klausner
Copyright (C) 2009-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>

View File

@ -1,6 +1,6 @@
/*
zip_source_read.c -- read data from zip_source
Copyright (C) 2009-2017 Dieter Baron and Thomas Klausner
Copyright (C) 2009-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>
@ -57,7 +57,7 @@ zip_source_read(zip_source_t *src, void *data, zip_uint64_t len) {
}
if (len == 0) {
return 0;
return 0;
}
bytes_read = 0;

View File

@ -1,6 +1,6 @@
/*
zip_source_remove.c -- remove empty archive
Copyright (C) 2014 Dieter Baron and Thomas Klausner
Copyright (C) 2014-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>

View File

@ -1,6 +1,6 @@
/*
zip_source_rollback_write.c -- discard changes
Copyright (C) 2014 Dieter Baron and Thomas Klausner
Copyright (C) 2014-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>

View File

@ -1,6 +1,6 @@
/*
zip_source_seek.c -- seek to offset
Copyright (C) 2014 Dieter Baron and Thomas Klausner
Copyright (C) 2014-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>
@ -50,7 +50,12 @@ zip_source_seek(zip_source_t *src, zip_int64_t offset, int whence) {
args.offset = offset;
args.whence = whence;
return (_zip_source_call(src, &args, sizeof(args), ZIP_SOURCE_SEEK) < 0 ? -1 : 0);
if (_zip_source_call(src, &args, sizeof(args), ZIP_SOURCE_SEEK) < 0) {
return -1;
}
src->eof = 0;
return 0;
}

View File

@ -1,6 +1,6 @@
/*
zip_source_seek_write.c -- seek to offset for writing
Copyright (C) 2014 Dieter Baron and Thomas Klausner
Copyright (C) 2014-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>

View File

@ -1,6 +1,6 @@
/*
zip_source_stat.c -- get meta information from zip_source
Copyright (C) 2009-2016 Dieter Baron and Thomas Klausner
Copyright (C) 2009-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>

View File

@ -1,6 +1,6 @@
/*
zip_source_supports.c -- check for supported functions
Copyright (C) 2014-2016 Dieter Baron and Thomas Klausner
Copyright (C) 2014-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>

View File

@ -1,6 +1,6 @@
/*
zip_source_tell.c -- report current offset
Copyright (C) 2014 Dieter Baron and Thomas Klausner
Copyright (C) 2014-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>

View File

@ -1,6 +1,6 @@
/*
zip_source_tell_write.c -- report current offset for writing
Copyright (C) 2014 Dieter Baron and Thomas Klausner
Copyright (C) 2014-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>

View File

@ -1,6 +1,6 @@
/*
zip_source_win32a.c -- create data source from Windows file (ANSI)
Copyright (C) 1999-2017 Dieter Baron and Thomas Klausner
Copyright (C) 1999-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>

View File

@ -1,6 +1,6 @@
/*
zip_source_win32file.c -- create data source from HANDLE (Win32)
Copyright (C) 1999-2016 Dieter Baron and Thomas Klausner
Copyright (C) 1999-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>

View File

@ -1,6 +1,6 @@
/*
zip_source_win32utf8.c -- create data source from Windows file (UTF-8)
Copyright (C) 1999-2015 Dieter Baron and Thomas Klausner
Copyright (C) 1999-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>

View File

@ -1,6 +1,6 @@
/*
zip_source_win32w.c -- create data source from Windows file (UTF-16)
Copyright (C) 1999-2017 Dieter Baron and Thomas Klausner
Copyright (C) 1999-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>

View File

@ -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;

View File

@ -1,6 +1,6 @@
/*
zip_source_write.c -- start a new file for writing
Copyright (C) 2014 Dieter Baron and Thomas Klausner
Copyright (C) 2014-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>

View File

@ -1,6 +1,6 @@
/*
zip_source_zip.c -- create data source from zip file
Copyright (C) 1999-2014 Dieter Baron and Thomas Klausner
Copyright (C) 1999-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>

View File

@ -1,6 +1,6 @@
/*
zip_source_zip_new.c -- prepare data structures for zip_fopen/zip_source_zip
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>

Some files were not shown because too many files have changed in this diff Show More