mirror of
https://github.com/zlib-ng/minizip-ng
synced 2026-08-25 14:26:08 -04:00
Fixed compiler warnings.
This commit is contained in:
parent
c7e852e33c
commit
e6b6616575
7 changed files with 46 additions and 41 deletions
|
|
@ -43,7 +43,7 @@ void derive_key(const unsigned char pwd[], /* the PASSWORD */
|
|||
hmac_ctx c1[1], c2[1], c3[1];
|
||||
|
||||
/* set HMAC context (c1) for password */
|
||||
h_size = hmac_sha_begin(HMAC_SHA1, c1);
|
||||
h_size = (unsigned int)hmac_sha_begin(HMAC_SHA1, c1);
|
||||
hmac_sha_key(pwd, pwd_len, c1);
|
||||
|
||||
/* set HMAC context (c2) for password and salt */
|
||||
|
|
|
|||
|
|
@ -77,14 +77,14 @@ typedef struct mz_stream_aes_s {
|
|||
int32_t mz_stream_aes_open(void *stream, const char *path, int32_t mode)
|
||||
{
|
||||
mz_stream_aes *aes = (mz_stream_aes *)stream;
|
||||
uint16_t salt_length = 0;
|
||||
uint16_t password_length = 0;
|
||||
uint16_t key_length = 0;
|
||||
uint8_t kbuf[2 * MZ_AES_KEY_LENGTH_MAX + MZ_AES_PW_VERIFY_SIZE];
|
||||
uint8_t verify[MZ_AES_PW_VERIFY_SIZE];
|
||||
uint8_t verify_expected[MZ_AES_PW_VERIFY_SIZE];
|
||||
uint8_t salt_value[MZ_AES_SALT_LENGTH_MAX];
|
||||
int32_t salt_length = 0;
|
||||
const char *password = path;
|
||||
int32_t password_length = 0;
|
||||
int32_t key_length = 0;
|
||||
|
||||
aes->total_in = 0;
|
||||
aes->total_out = 0;
|
||||
|
|
@ -97,7 +97,7 @@ int32_t mz_stream_aes_open(void *stream, const char *path, int32_t mode)
|
|||
password = aes->password;
|
||||
if (password == NULL)
|
||||
return MZ_PARAM_ERROR;
|
||||
password_length = (int32_t)strlen(password);
|
||||
password_length = (uint16_t)strlen(password);
|
||||
if (password_length > MZ_AES_PW_LENGTH_MAX)
|
||||
return MZ_PARAM_ERROR;
|
||||
|
||||
|
|
@ -215,7 +215,7 @@ int32_t mz_stream_aes_read(void *stream, void *buf, int32_t size)
|
|||
read = mz_stream_read(aes->stream.base, buf, size);
|
||||
if (read > 0)
|
||||
{
|
||||
hmac_sha_data((uint8_t *)buf, read, aes->auth_ctx);
|
||||
hmac_sha_data((uint8_t *)buf, (uint32_t)read, aes->auth_ctx);
|
||||
mz_stream_aes_encrypt_data(stream, (uint8_t *)buf, read);
|
||||
}
|
||||
|
||||
|
|
@ -228,12 +228,14 @@ int32_t mz_stream_aes_write(void *stream, const void *buf, int32_t size)
|
|||
mz_stream_aes *aes = (mz_stream_aes *)stream;
|
||||
int32_t written = 0;
|
||||
|
||||
if (size < 0)
|
||||
return MZ_PARAM_ERROR;
|
||||
if (size > (int32_t)sizeof(aes->buffer))
|
||||
return MZ_STREAM_ERROR;
|
||||
|
||||
memcpy(aes->buffer, buf, size);
|
||||
mz_stream_aes_encrypt_data(stream, (uint8_t *)aes->buffer, size);
|
||||
hmac_sha_data((uint8_t *)aes->buffer, size, aes->auth_ctx);
|
||||
hmac_sha_data((uint8_t *)aes->buffer, (uint32_t)size, aes->auth_ctx);
|
||||
|
||||
written = mz_stream_write(aes->stream.base, aes->buffer, size);
|
||||
if (written > 0)
|
||||
|
|
|
|||
|
|
@ -123,10 +123,10 @@ int32_t mz_stream_crc32_error(void *stream)
|
|||
return mz_stream_error(crc32->stream.base);
|
||||
}
|
||||
|
||||
int32_t mz_stream_crc32_get_value(void *stream)
|
||||
uint32_t mz_stream_crc32_get_value(void *stream)
|
||||
{
|
||||
mz_stream_crc32 *crc32 = (mz_stream_crc32 *)stream;
|
||||
return (int32_t)crc32->value;
|
||||
return crc32->value;
|
||||
}
|
||||
|
||||
int32_t mz_stream_crc32_get_prop_int64(void *stream, int32_t prop, int64_t *value)
|
||||
|
|
@ -155,17 +155,16 @@ void *mz_stream_crc32_create(void **stream)
|
|||
{
|
||||
memset(crc32, 0, sizeof(mz_stream_crc32));
|
||||
crc32->stream.vtbl = &mz_stream_crc32_vtbl;
|
||||
}
|
||||
|
||||
#ifdef HAVE_ZLIB
|
||||
crc32->update =
|
||||
(mz_stream_crc32_update)mz_stream_zlib_get_crc32_update();
|
||||
crc32->update =
|
||||
(mz_stream_crc32_update)mz_stream_zlib_get_crc32_update();
|
||||
#elif defined(HAVE_LZMA)
|
||||
crc32->update =
|
||||
(mz_stream_crc32_update)mz_stream_lzma_get_crc32_update();
|
||||
crc32->update =
|
||||
(mz_stream_crc32_update)mz_stream_lzma_get_crc32_update();
|
||||
#else
|
||||
#error ZLIB or LZMA required for CRC32
|
||||
#endif
|
||||
}
|
||||
|
||||
if (stream != NULL)
|
||||
*stream = crc32;
|
||||
|
|
|
|||
|
|
@ -22,24 +22,24 @@ extern "C" {
|
|||
|
||||
typedef int64_t (*mz_stream_crc32_update)(int64_t value, const void *buf, int32_t size);
|
||||
|
||||
int32_t mz_stream_crc32_open(void *stream, const char *filename, int32_t mode);
|
||||
int32_t mz_stream_crc32_is_open(void *stream);
|
||||
int32_t mz_stream_crc32_read(void *stream, void *buf, int32_t size);
|
||||
int32_t mz_stream_crc32_write(void *stream, const void *buf, int32_t size);
|
||||
int64_t mz_stream_crc32_tell(void *stream);
|
||||
int32_t mz_stream_crc32_seek(void *stream, int64_t offset, int32_t origin);
|
||||
int32_t mz_stream_crc32_close(void *stream);
|
||||
int32_t mz_stream_crc32_error(void *stream);
|
||||
int32_t mz_stream_crc32_open(void *stream, const char *filename, int32_t mode);
|
||||
int32_t mz_stream_crc32_is_open(void *stream);
|
||||
int32_t mz_stream_crc32_read(void *stream, void *buf, int32_t size);
|
||||
int32_t mz_stream_crc32_write(void *stream, const void *buf, int32_t size);
|
||||
int64_t mz_stream_crc32_tell(void *stream);
|
||||
int32_t mz_stream_crc32_seek(void *stream, int64_t offset, int32_t origin);
|
||||
int32_t mz_stream_crc32_close(void *stream);
|
||||
int32_t mz_stream_crc32_error(void *stream);
|
||||
|
||||
int32_t mz_stream_crc32_get_value(void *stream);
|
||||
uint32_t mz_stream_crc32_get_value(void *stream);
|
||||
|
||||
int32_t mz_stream_crc32_get_prop_int64(void *stream, int32_t prop, int64_t *value);
|
||||
int32_t mz_stream_crc32_get_prop_int64(void *stream, int32_t prop, int64_t *value);
|
||||
|
||||
void* mz_stream_crc32_create(void **stream);
|
||||
void mz_stream_crc32_delete(void **stream);
|
||||
void* mz_stream_crc32_create(void **stream);
|
||||
void mz_stream_crc32_delete(void **stream);
|
||||
|
||||
void* mz_stream_crc32_get_interface(void);
|
||||
int32_t mz_stream_crc32_get_update_func(mz_stream_crc32_update *update);
|
||||
void* mz_stream_crc32_get_interface(void);
|
||||
int32_t mz_stream_crc32_get_update_func(mz_stream_crc32_update *update);
|
||||
|
||||
/***************************************************************************/
|
||||
|
||||
|
|
|
|||
|
|
@ -72,13 +72,13 @@ typedef struct mz_stream_pkcrypt_s {
|
|||
|
||||
/***************************************************************************/
|
||||
|
||||
#define mz_stream_pkcrypt_decode(strm, c) \
|
||||
(mz_stream_pkcrypt_update_keys(strm, \
|
||||
#define mz_stream_pkcrypt_decode(strm, c) \
|
||||
(mz_stream_pkcrypt_update_keys(strm, \
|
||||
c ^= mz_stream_pkcrypt_decrypt_byte(strm)))
|
||||
|
||||
#define mz_stream_pkcrypt_encode(strm, c, t) \
|
||||
(t = mz_stream_pkcrypt_decrypt_byte(strm), \
|
||||
mz_stream_pkcrypt_update_keys(strm, c), t^(c))
|
||||
#define mz_stream_pkcrypt_encode(strm, c, t) \
|
||||
(t = mz_stream_pkcrypt_decrypt_byte(strm), \
|
||||
mz_stream_pkcrypt_update_keys(strm, (uint8_t)c), (uint8_t)(t^(c)))
|
||||
|
||||
/***************************************************************************/
|
||||
|
||||
|
|
@ -121,7 +121,7 @@ static void mz_stream_pkcrypt_init_keys(void *stream, const char *password)
|
|||
|
||||
while (*password != 0)
|
||||
{
|
||||
mz_stream_pkcrypt_update_keys(stream, *password);
|
||||
mz_stream_pkcrypt_update_keys(stream, (uint8_t)*password);
|
||||
password += 1;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -55,9 +55,9 @@ typedef struct mz_stream_split_s {
|
|||
int64_t total_out_disk;
|
||||
int32_t mode;
|
||||
char *path_cd;
|
||||
int32_t path_cd_size;
|
||||
uint32_t path_cd_size;
|
||||
char *path_disk;
|
||||
int32_t path_disk_size;
|
||||
uint32_t path_disk_size;
|
||||
int32_t number_disk;
|
||||
int32_t current_disk;
|
||||
int32_t reached_end;
|
||||
|
|
@ -90,7 +90,7 @@ static int32_t mz_stream_split_open_disk(void *stream, int32_t number_disk)
|
|||
{
|
||||
if (split->path_disk[i] != '.')
|
||||
continue;
|
||||
snprintf(&split->path_disk[i], split->path_disk_size - i, ".z%02d", number_disk + 1);
|
||||
snprintf(&split->path_disk[i], split->path_disk_size - (uint32_t)i, ".z%02d", number_disk + 1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
@ -180,7 +180,7 @@ int32_t mz_stream_split_open(void *stream, const char *path, int32_t mode)
|
|||
|
||||
split->mode = mode;
|
||||
|
||||
split->path_cd_size = (int32_t)strlen(path) + 1;
|
||||
split->path_cd_size = (uint32_t)strlen(path) + 1;
|
||||
split->path_cd = (char *)MZ_ALLOC(split->path_cd_size);
|
||||
|
||||
if (split->path_cd == NULL)
|
||||
|
|
@ -189,7 +189,7 @@ int32_t mz_stream_split_open(void *stream, const char *path, int32_t mode)
|
|||
strncpy(split->path_cd, path, split->path_cd_size - 1);
|
||||
split->path_cd[split->path_cd_size - 1] = 0;
|
||||
|
||||
split->path_disk_size = (int32_t)strlen(path) + 10;
|
||||
split->path_disk_size = (uint32_t)strlen(path) + 10;
|
||||
split->path_disk = (char *)MZ_ALLOC(split->path_disk_size);
|
||||
|
||||
if (split->path_disk == NULL)
|
||||
|
|
|
|||
|
|
@ -530,7 +530,7 @@ int32_t mz_zip_reader_entry_save_file(void *handle, const char *path)
|
|||
err_attrib = mz_zip_attrib_convert(MZ_HOST_SYSTEM(reader->file_info->version_madeby), reader->file_info->external_fa,
|
||||
MZ_VERSION_MADEBY_HOST_SYSTEM, &target_attrib);
|
||||
if (err_attrib == MZ_OK)
|
||||
err_attrib = mz_os_set_file_attribs(path, target_attrib);
|
||||
mz_os_set_file_attribs(path, target_attrib);
|
||||
}
|
||||
|
||||
return err;
|
||||
|
|
@ -1082,7 +1082,11 @@ int32_t mz_zip_writer_add_info(void *handle, void *stream, mz_stream_read_cb rea
|
|||
if (stream != NULL)
|
||||
{
|
||||
if (mz_zip_attrib_is_dir(writer->file_info.external_fa, writer->file_info.version_madeby) != MZ_OK)
|
||||
{
|
||||
err = mz_zip_writer_add(handle, stream, read_cb);
|
||||
if (err != MZ_OK)
|
||||
return err;
|
||||
}
|
||||
}
|
||||
|
||||
err = mz_zip_writer_entry_close(handle);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue