Disable md5 checking on apple for now till someone fixes it.

This commit is contained in:
ckolivas 2011-04-13 14:50:26 +10:00
parent 271e97d8be
commit 127a101b14
3 changed files with 31 additions and 16 deletions

View file

@ -101,6 +101,7 @@ void write_magic(rzip_control *control)
* which can be used as an integrity check instead of crc check. * which can be used as an integrity check instead of crc check.
* crc is still stored for compatibility with 0.5 versions. * crc is still stored for compatibility with 0.5 versions.
*/ */
if (!NO_MD5)
magic[21] = 1; magic[21] = 1;
if (ENCRYPT) if (ENCRYPT)
magic[22] = 1; magic[22] = 1;
@ -155,7 +156,7 @@ static void get_magic(rzip_control *control, char *magic)
/* Whether this archive contains md5 data at the end or not */ /* Whether this archive contains md5 data at the end or not */
md5 = magic[21]; md5 = magic[21];
if (md5) { if (md5 && MD5_RELIABLE) {
if (md5 == 1) if (md5 == 1)
control->flags |= FLAG_MD5; control->flags |= FLAG_MD5;
else else
@ -961,6 +962,8 @@ void compress_file(rzip_control *control)
int fd_in, fd_out = -1; int fd_in, fd_out = -1;
char header[MAGIC_LEN]; char header[MAGIC_LEN];
if (MD5_RELIABLE)
control->flags |= FLAG_MD5;
if (ENCRYPT) if (ENCRYPT)
get_hash(control, 1); get_hash(control, 1);
memset(header, 0, sizeof(header)); memset(header, 0, sizeof(header));

View file

@ -95,6 +95,12 @@ typedef struct md5_ctx md5_ctx;
#define mremap fake_mremap #define mremap fake_mremap
#endif #endif
#if defined(__APPLE__)
# define MD5_RELIABLE (0)
#else
# define MD5_RELIABLE (1)
#endif
#define bswap_32(x) \ #define bswap_32(x) \
((((x) & 0xff000000) >> 24) | (((x) & 0x00ff0000) >> 8) | \ ((((x) & 0xff000000) >> 24) | (((x) & 0x00ff0000) >> 8) | \
(((x) & 0x0000ff00) << 8) | (((x) & 0x000000ff) << 24)) (((x) & 0x0000ff00) << 8) | (((x) & 0x000000ff) << 24))

6
rzip.c
View file

@ -624,6 +624,7 @@ static void hash_search(rzip_control *control, struct rzip_state *st, double pct
for (i = 0; i < n; i++) for (i = 0; i < n; i++)
memcpy(ckbuf + i, get_sb(control, cksum_limit + i), 1); memcpy(ckbuf + i, get_sb(control, cksum_limit + i), 1);
st->cksum = CrcUpdate(st->cksum, ckbuf, n); st->cksum = CrcUpdate(st->cksum, ckbuf, n);
if (!NO_MD5)
md5_process_bytes(ckbuf, n, &control->ctx); md5_process_bytes(ckbuf, n, &control->ctx);
cksum_limit += n; cksum_limit += n;
free(ckbuf); free(ckbuf);
@ -645,6 +646,7 @@ static void hash_search(rzip_control *control, struct rzip_state *st, double pct
for (i = 0; i < n; i++) for (i = 0; i < n; i++)
memcpy(ckbuf + i, get_sb(control, cksum_limit + i), 1); memcpy(ckbuf + i, get_sb(control, cksum_limit + i), 1);
st->cksum = CrcUpdate(st->cksum, ckbuf, n); st->cksum = CrcUpdate(st->cksum, ckbuf, n);
if (!NO_MD5)
md5_process_bytes(ckbuf, n, &control->ctx); md5_process_bytes(ckbuf, n, &control->ctx);
cksum_limit += n; cksum_limit += n;
free(ckbuf); free(ckbuf);
@ -773,6 +775,7 @@ void rzip_fd(rzip_control *control, int fd_in, int fd_out)
double chunkmbs; double chunkmbs;
i64 free_space; i64 free_space;
if (!NO_MD5)
md5_init_ctx (&control->ctx); md5_init_ctx (&control->ctx);
st = calloc(sizeof(*st), 1); st = calloc(sizeof(*st), 1);
@ -975,6 +978,8 @@ retry:
if (likely(st->hash_table)) if (likely(st->hash_table))
free(st->hash_table); free(st->hash_table);
if (!NO_MD5) {
/* Temporary workaround till someone fixes apple md5 */
md5_finish_ctx(&control->ctx, md5_resblock); md5_finish_ctx(&control->ctx, md5_resblock);
if (HASH_CHECK || MAX_VERBOSE) { if (HASH_CHECK || MAX_VERBOSE) {
print_output("MD5: "); print_output("MD5: ");
@ -987,6 +992,7 @@ retry:
lrz_encrypt(control, md5_resblock, MD5_DIGEST_SIZE, control->salt_pass); lrz_encrypt(control, md5_resblock, MD5_DIGEST_SIZE, control->salt_pass);
if (unlikely(write_1g(control, md5_resblock, MD5_DIGEST_SIZE) != MD5_DIGEST_SIZE)) if (unlikely(write_1g(control, md5_resblock, MD5_DIGEST_SIZE) != MD5_DIGEST_SIZE))
fatal("Failed to write md5 in rzip_fd\n"); fatal("Failed to write md5 in rzip_fd\n");
}
if (TMP_OUTBUF) if (TMP_OUTBUF)
flush_tmpoutbuf(control); flush_tmpoutbuf(control);