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,7 +101,8 @@ void write_magic(rzip_control *control)
* which can be used as an integrity check instead of crc check.
* crc is still stored for compatibility with 0.5 versions.
*/
magic[21] = 1;
if (!NO_MD5)
magic[21] = 1;
if (ENCRYPT)
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 */
md5 = magic[21];
if (md5) {
if (md5 && MD5_RELIABLE) {
if (md5 == 1)
control->flags |= FLAG_MD5;
else
@ -961,6 +962,8 @@ void compress_file(rzip_control *control)
int fd_in, fd_out = -1;
char header[MAGIC_LEN];
if (MD5_RELIABLE)
control->flags |= FLAG_MD5;
if (ENCRYPT)
get_hash(control, 1);
memset(header, 0, sizeof(header));

View file

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

34
rzip.c
View file

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