AES FIX
This commit is contained in:
@@ -5,7 +5,6 @@
|
||||
// Created by Sam Soffes on 7/21/10.
|
||||
// Copyright (c) Sam Soffes 2010-2015. All rights reserved.
|
||||
//
|
||||
|
||||
#import "SSZipArchive.h"
|
||||
#include "unzip.h"
|
||||
#include "zip.h"
|
||||
@@ -15,7 +14,6 @@
|
||||
#include <sys/stat.h>
|
||||
|
||||
#define CHUNK 16384
|
||||
#define HAVE_AES
|
||||
|
||||
@interface SSZipArchive ()
|
||||
+ (NSDate *)_dateWithMSDOSFormat:(UInt32)msdosDateTime;
|
||||
@@ -120,6 +118,7 @@
|
||||
BOOL success = YES;
|
||||
BOOL canceled = NO;
|
||||
int ret = 0;
|
||||
int crc_ret =0;
|
||||
unsigned char buffer[4096] = {0};
|
||||
NSFileManager *fileManager = [NSFileManager defaultManager];
|
||||
NSMutableSet *directoriesModificationDates = [[NSMutableSet alloc] init];
|
||||
@@ -232,6 +231,7 @@
|
||||
[directoriesModificationDates addObject: @{@"path": fullPath, @"modDate": modDate}];
|
||||
|
||||
if ([fileManager fileExistsAtPath:fullPath] && !isDirectory && !overwrite) {
|
||||
//FIXME: couldBe CRC Check?
|
||||
unzCloseCurrentFile(zip);
|
||||
ret = unzGoToNextFile(zip);
|
||||
continue;
|
||||
@@ -317,7 +317,11 @@
|
||||
}
|
||||
}
|
||||
|
||||
unzCloseCurrentFile( zip );
|
||||
crc_ret = unzCloseCurrentFile( zip );
|
||||
if (crc_ret == UNZ_CRCERROR) {
|
||||
//CRC ERROR
|
||||
return NO;
|
||||
}
|
||||
ret = unzGoToNextFile( zip );
|
||||
|
||||
// Message delegate
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -17,6 +17,8 @@
|
||||
#ifndef _UNZ_H
|
||||
#define _UNZ_H
|
||||
|
||||
#define HAVE_AES
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
+368
-479
File diff suppressed because it is too large
Load Diff
@@ -15,6 +15,8 @@
|
||||
#ifndef _ZIP_H
|
||||
#define _ZIP_H
|
||||
|
||||
#define HAVE_AES
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user