This commit is contained in:
Sen
2015-10-29 10:14:32 +08:00
parent c601929993
commit c2bd1bd51b
6 changed files with 400 additions and 502 deletions
+16 -15
View File
@@ -3,12 +3,13 @@
#else
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#endif
#if defined(__cplusplus)
extern "C"
{
#endif
#if defined(__cplusplus)
extern "C"
{
#endif
#ifdef _WIN32
int entropy_fun(unsigned char buf[], unsigned int len)
@@ -37,17 +38,17 @@ int entropy_fun(unsigned char buf[], unsigned int len)
#else
int entropy_fun(unsigned char buf[], unsigned int len)
{
int frand = open("/dev/random", O_RDONLY);
int rlen = 0;
if (frand != -1)
{
rlen = read(frand, buf, len);
int frand = open("/dev/random", O_RDONLY);
int rlen = 0;
if (frand != -1)
{
rlen = (int)read(frand, buf, len);
close(frand);
}
return rlen;
}
#endif
#if defined(__cplusplus)
}
#endif
#endif
#if defined(__cplusplus)
}
#endif
+5 -5
View File
@@ -853,16 +853,16 @@ local int unz64local_GetCurrentFileInfoInternal(unzFile file, unz_file_info64 *p
if (uL != 1 && uL != 2)
err = UNZ_ERRNO;
file_info_internal.aes_version = uL;
if (unz64local_getByte(&s->z_filefunc, s->filestream_with_CD, &uL) != UNZ_OK)
if (unz64local_getByte(&s->z_filefunc, s->filestream_with_CD, (int *)&uL) != UNZ_OK)
err = UNZ_ERRNO;
if ((char)uL != 'A')
err = UNZ_ERRNO;
if (unz64local_getByte(&s->z_filefunc, s->filestream_with_CD, &uL) != UNZ_OK)
if (unz64local_getByte(&s->z_filefunc, s->filestream_with_CD, (int *)&uL) != UNZ_OK)
err = UNZ_ERRNO;
if ((char)uL != 'E')
err = UNZ_ERRNO;
/* Get AES encryption strength and actual compression method */
if (unz64local_getByte(&s->z_filefunc, s->filestream_with_CD, &uL) != UNZ_OK)
if (unz64local_getByte(&s->z_filefunc, s->filestream_with_CD, (int *)&uL) != UNZ_OK)
err = UNZ_ERRNO;
file_info_internal.aes_encryption_mode = uL;
if (unz64local_getShort(&s->z_filefunc, s->filestream_with_CD, &uL) != UNZ_OK)
@@ -1202,7 +1202,7 @@ extern int ZEXPORT unzOpenCurrentFile3(unzFile file, int *method, int *level, in
if (ZREAD64(s->z_filefunc, s->filestream, passverify, AES_PWVERIFYSIZE) != AES_PWVERIFYSIZE)
return UNZ_INTERNALERROR;
fcrypt_init(s->cur_file_info_internal.aes_encryption_mode, password, strlen(password), saltvalue,
fcrypt_init((int)s->cur_file_info_internal.aes_encryption_mode, (unsigned char *)password, (unsigned int)strlen(password), saltvalue,
passverify, &s->pfile_in_zip_read->aes_ctx);
pfile_in_zip_read_info->rest_read_compressed -= saltlength + AES_PWVERIFYSIZE;
@@ -1293,7 +1293,7 @@ extern int ZEXPORT unzReadCurrentFile(unzFile file, voidp buf, unsigned len)
if (pfile_in_zip_read_info->stream.next_in != NULL)
bytes_not_read = (uInt)(pfile_in_zip_read_info->read_buffer + UNZ_BUFSIZE -
pfile_in_zip_read_info->stream.next_in);
pfile_in_zip_read_info->stream.next_in);
bytes_to_read -= bytes_not_read;
if (bytes_not_read > 0)
memcpy(pfile_in_zip_read_info->read_buffer, pfile_in_zip_read_info->stream.next_in, bytes_not_read);
+2
View File
@@ -17,6 +17,8 @@
#ifndef _UNZ_H
#define _UNZ_H
#define HAVE_AES
#ifdef __cplusplus
extern "C" {
#endif
+368 -479
View File
File diff suppressed because it is too large Load Diff
+2
View File
@@ -15,6 +15,8 @@
#ifndef _ZIP_H
#define _ZIP_H
#define HAVE_AES
#ifdef __cplusplus
extern "C" {
#endif