*
* Copyright (C) 1996 Andrew Tridgell
* Copyright (C) 1996 Paul Mackerras
- * Copyright (C) 2004, 2005 Wayne Davison
+ * Copyright (C) 2004-2007 Wayne Davison
*
* This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
#include "rsync.h"
-int csum_length=2; /* initial value */
+int csum_length = SHORT_SUM_LENGTH; /* initial value */
#define CSUM_CHUNK 64
void file_checksum(char *fname,char *sum,OFF_T size)
{
- OFF_T i;
struct map_struct *buf;
- int fd;
- OFF_T len = size;
+ OFF_T i, len = size;
struct mdfour m;
+ int32 remainder;
+ int fd;
memset(sum,0,MD4_SUM_LENGTH);
* 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 || protocol_version >= 27)
- mdfour_update(&m, (uchar *)map_ptr(buf, i, len-i), len-i);
+ remainder = (int32)(len - i);
+ if (remainder > 0 || protocol_version >= 27)
+ mdfour_update(&m, (uchar *)map_ptr(buf, i, remainder), remainder);
mdfour_result(&m, (uchar *)sum);