X-Git-Url: https://mattmccutchen.net/rsync/rsync-patches.git/blobdiff_plain/1680e81416c7e5c3acd1b473cdabfadae9efca70..2f999b32b511a750e0b3535377d079bedeb844e4:/md5.diff diff --git a/md5.diff b/md5.diff index f9c5cd3..4f4254a 100644 --- a/md5.diff +++ b/md5.diff @@ -1,6 +1,15 @@ ---- orig/Makefile.in 2005-07-07 23:11:07 -+++ Makefile.in 2005-06-14 02:33:20 -@@ -26,7 +26,7 @@ VERSION=@VERSION@ +This patch adds the --md5 option, which makes rsync use md5 checksums +instead of md4. + +To use this patch, run these commands for a successful build: + + patch -p1 len1) { if (buf1) -@@ -65,7 +68,10 @@ void get_checksum2(char *buf, int32 len, +@@ -68,7 +71,10 @@ void get_checksum2(char *buf, int32 len, out_of_memory("get_checksum2"); } @@ -47,7 +56,7 @@ memcpy(buf1,buf,len); if (checksum_seed) { -@@ -74,7 +80,10 @@ void get_checksum2(char *buf, int32 len, +@@ -77,7 +83,10 @@ void get_checksum2(char *buf, int32 len, } for(i = 0; i + CSUM_CHUNK <= len; i += CSUM_CHUNK) { @@ -59,7 +68,7 @@ } /* * Prior to version 27 an incorrect MD4 checksum was computed -@@ -83,10 +92,16 @@ void get_checksum2(char *buf, int32 len, +@@ -86,10 +95,16 @@ void get_checksum2(char *buf, int32 len, * even when there are no more bytes. */ if (len - i > 0 || protocol_version >= 27) { @@ -78,15 +87,15 @@ } -@@ -97,6 +112,7 @@ void file_checksum(char *fname,char *sum - int fd; - OFF_T len = size; +@@ -99,6 +114,7 @@ void file_checksum(char *fname,char *sum + OFF_T i, len = size; struct mdfour m; + int32 remainder; + md5_context ctx; + int fd; memset(sum,0,MD4_SUM_LENGTH); - -@@ -106,21 +122,36 @@ void file_checksum(char *fname,char *sum +@@ -109,11 +125,19 @@ void file_checksum(char *fname,char *sum buf = map_file(fd, size, MAX_MAP_SIZE, CSUM_CHUNK); @@ -109,16 +118,17 @@ } /* Prior to version 27 an incorrect MD4 checksum was computed - * by failing to call mdfour_tail() for block sizes that +@@ -121,10 +145,17 @@ void file_checksum(char *fname,char *sum * are multiples of 64. This is fixed by calling mdfour_update() * even when there are no more bytes. */ -- if (len - i > 0 || protocol_version >= 27) -- mdfour_update(&m, (uchar *)map_ptr(buf, i, len-i), len-i); -+ if (len - i > 0 || protocol_version >= 27) { + remainder = (int32)(len - i); +- if (remainder > 0 || protocol_version >= 27) +- mdfour_update(&m, (uchar *)map_ptr(buf, i, remainder), remainder); ++ if (remainder > 0 || protocol_version >= 27) { + if (use_md5) -+ md5_update(&ctx, (uchar *)map_ptr(buf, i, len-i), len-i); ++ md5_update(&ctx, (uchar *)map_ptr(buf, i, remainder), remainder); + else -+ mdfour_update(&m, (uchar *)map_ptr(buf, i, len-i), len-i); ++ mdfour_update(&m, (uchar *)map_ptr(buf, i, remainder), remainder); + } - mdfour_result(&m, (uchar *)sum); @@ -129,7 +139,7 @@ close(fd); unmap_file(buf); -@@ -130,11 +161,15 @@ void file_checksum(char *fname,char *sum +@@ -134,11 +165,15 @@ void file_checksum(char *fname,char *sum static int32 sumresidue; static char sumrbuf[CSUM_CHUNK]; static struct mdfour md; @@ -146,7 +156,7 @@ sumresidue = 0; SIVAL(s, 0, seed); sum_update(s, 4); -@@ -159,13 +194,19 @@ void sum_update(char *p, int32 len) +@@ -163,13 +198,19 @@ void sum_update(const char *p, int32 len if (sumresidue) { int32 i = CSUM_CHUNK - sumresidue; memcpy(sumrbuf + sumresidue, p, i); @@ -168,7 +178,7 @@ len -= CSUM_CHUNK; p += CSUM_CHUNK; } -@@ -177,8 +218,15 @@ void sum_update(char *p, int32 len) +@@ -181,8 +222,15 @@ void sum_update(const char *p, int32 len void sum_end(char *sum) { @@ -187,8 +197,8 @@ + else + mdfour_result(&md, (uchar *)sum); } ---- orig/lib/md5.c 2005-06-14 02:35:52 -+++ lib/md5.c 2005-06-14 02:35:52 +--- old/lib/md5.c ++++ new/lib/md5.c @@ -0,0 +1,344 @@ +/* + * RFC 1321 compliant MD5 implementation @@ -534,8 +544,8 @@ +} + +#endif ---- orig/lib/md5.h 2005-06-14 02:35:26 -+++ lib/md5.h 2005-06-14 02:35:26 +--- old/lib/md5.h ++++ new/lib/md5.h @@ -0,0 +1,14 @@ +#ifndef _MD5_H +#define _MD5_H @@ -551,17 +561,17 @@ +void md5_finish(md5_context *ctx, uchar digest[16]); + +#endif /* md5.h */ ---- orig/options.c 2005-05-19 08:52:42 -+++ options.c 2005-06-14 02:21:26 -@@ -107,6 +107,7 @@ int inplace = 0; - int delay_updates = 0; - long block_size = 0; /* "long" because popt can't set an int32. */ - +--- old/options.c ++++ new/options.c +@@ -101,6 +101,7 @@ int copy_unsafe_links = 0; + int size_only = 0; + int daemon_bwlimit = 0; + int bwlimit = 0; +int use_md5 = 0; - - /** Network address family. **/ - #ifdef INET6 -@@ -348,6 +349,7 @@ void usage(enum logcode F) + int fuzzy_basis = 0; + size_t bwlimit_writemax = 0; + int ignore_existing = 0; +@@ -378,6 +379,7 @@ void usage(enum logcode F) rprintf(F," --only-write-batch=FILE like --write-batch but w/o updating destination\n"); rprintf(F," --read-batch=FILE read a batched update from FILE\n"); rprintf(F," --protocol=NUM force an older protocol version to be used\n"); @@ -569,15 +579,15 @@ #ifdef INET6 rprintf(F," -4, --ipv4 prefer IPv4\n"); rprintf(F," -6, --ipv6 prefer IPv6\n"); -@@ -460,6 +462,7 @@ static struct poptOption long_options[] - {"no-implied-dirs", 0, POPT_ARG_VAL, &implied_dirs, 0, 0, 0 }, - {"protocol", 0, POPT_ARG_INT, &protocol_version, 0, 0, 0 }, - {"checksum-seed", 0, POPT_ARG_INT, &checksum_seed, 0, 0, 0 }, +@@ -492,6 +494,7 @@ static struct poptOption long_options[] + {"whole-file", 'W', POPT_ARG_VAL, &whole_file, 1, 0, 0 }, + {"no-whole-file", 0, POPT_ARG_VAL, &whole_file, 0, 0, 0 }, + {"no-W", 0, POPT_ARG_VAL, &whole_file, 0, 0, 0 }, + {"md5", 0, POPT_ARG_NONE, &use_md5, 0, 0, 0 }, - #ifdef INET6 - {"ipv4", '4', POPT_ARG_VAL, &default_af_hint, AF_INET, 0, 0 }, - {"ipv6", '6', POPT_ARG_VAL, &default_af_hint, AF_INET6, 0, 0 }, -@@ -1365,6 +1368,9 @@ void server_options(char **args,int *arg + {"checksum", 'c', POPT_ARG_NONE, &always_checksum, 0, 0, 0 }, + {"block-size", 'B', POPT_ARG_LONG, &block_size, 0, 0, 0 }, + {"compare-dest", 0, POPT_ARG_STRING, 0, OPT_COMPARE_DEST, 0, 0 }, +@@ -1656,6 +1659,9 @@ void server_options(char **args,int *arg args[ac++] = arg; }