MD4 checksum fix

jw schultz jw at pegasys.ws
Thu Apr 10 11:37:53 EST 2003


I'm merging now and have a couple of questions.
These came up because i noticed the indentation was off.

On Sat, Apr 05, 2003 at 04:06:25PM -0800, cbarratt at users.sourceforge.net wrote:
> ###########################################################################
> diff -bur rsync-2.5.6/checksum.c rsync-2.5.6-fixed-md4/checksum.c
> --- rsync-2.5.6/checksum.c	2002-04-08 01:29:04.000000000 -0700
> +++ rsync-2.5.6-fixed-md4/checksum.c	2003-04-05 16:03:15.000000000 -0800
> @@ -74,7 +74,13 @@
>  	for(i = 0; i + CSUM_CHUNK <= len; i += CSUM_CHUNK) {
>  		mdfour_update(&m, (uchar *)(buf1+i), CSUM_CHUNK);
>  	}
> -	if (len - i > 0) {
> +	/*
> +	 * Prior to version 27 an incorrect MD4 checksum was computed
> +	 * by failing to call mdfour_tail() for block sizes that
> +	 * are multiples of 64.  This is fixed by calling mdfour_update()
> +	 * even when there are no more bytes.
> +	 */
> +	if (len - i > 0 || (remote_version >= 27 && len - i == 0)) {

I don't see how (len - i < 0) could be true so this should be
+	if (len - i > 0 || remote_version >= 27) {

>  		mdfour_update(&m, (uchar *)(buf1+i), (len-i));
>  	}
>  	
> @@ -105,8 +111,16 @@
>  		mdfour_update(&m, (uchar *)tmpchunk, CSUM_CHUNK);
>  	}
>  
> +	/*
> +	 * Prior to version 27 an incorrect MD4 checksum was computed
> +	 * by failing to call mdfour_tail() for block sizes that
> +	 * are multiples of 64.  This is fixed by calling mdfour_update()
> +	 * even when there are no more bytes.
> +	 */
> +	if (len - i > 0 || (remote_version >= 27 && len - i == 0)) {
>  	if (len - i > 0) {
>  		memcpy(tmpchunk, map_ptr(buf,i,len-i), len-i);
> +		}
>  		mdfour_update(&m, (uchar *)tmpchunk, (len-i));
>  	}
Likewise here.  (len - i < 0) seems impossible and this code
is a messy anyway.

	if (len - i > 0) {
		memcpy(tmpchunk, map_ptr(buf,i,len-i), len-i);
	}
	if (len - i > 0 || remote_version >= 27) {
 		mdfour_update(&m, (uchar *)tmpchunk, (len-i));
 	}


-- 
________________________________________________________________
	J.W. Schultz            Pegasystems Technologies
	email address:		jw at pegasys.ws

		Remember Cernan and Schmitt


More information about the rsync mailing list