7b2a78a
--- a/util.c
7b2a78a
+++ b/util.c
7b2a78a
@@ -1329,7 +1329,7 @@ void *_new_array(unsigned long num, unsigned int size, int use_calloc)
7b2a78a
 	return use_calloc ? calloc(num, size) : malloc(num * size);
7b2a78a
 }
7b2a78a
 
7b2a78a
-void *_realloc_array(void *ptr, unsigned int size, unsigned long num)
7b2a78a
+void *_realloc_array(void *ptr, unsigned int size, size_t num)
7b2a78a
 {
7b2a78a
 	if (num >= MALLOC_MAX/size)
7b2a78a
 		return NULL;
7b2a78a
@@ -1550,7 +1550,10 @@ void *expand_item_list(item_list *lp, size_t item_size,
7b2a78a
 			new_size += incr;
7b2a78a
 		else
7b2a78a
 			new_size *= 2;
7b2a78a
-		new_ptr = realloc_array(lp->items, char, new_size * item_size);
7b2a78a
+		if (new_size < lp->malloced)
7b2a78a
+			overflow_exit("expand_item_list");
7b2a78a
+		/* Using _realloc_array() lets us pass the size, not a type. */
7b2a78a
+		new_ptr = _realloc_array(lp->items, item_size, new_size);
7b2a78a
 		if (verbose >= 4) {
7b2a78a
 			rprintf(FINFO, "[%s] expand %s to %.0f bytes, did%s move\n",
7b2a78a
 				who_am_i(), desc, (double)new_size * item_size,
d65be0f
diff -uPr rsync-2.6.9.orig/proto.h rsync-2.6.9/proto.h
d65be0f
--- rsync-2.6.9.orig/proto.h	2008-04-08 16:44:42.000000000 -0400
d65be0f
+++ rsync-2.6.9/proto.h	2008-04-09 10:23:52.000000000 -0400
d65be0f
@@ -322,7 +322,7 @@
d65be0f
 int cmp_time(time_t file1, time_t file2);
d65be0f
 int _Insure_trap_error(int a1, int a2, int a3, int a4, int a5, int a6);
d65be0f
 void *_new_array(unsigned int size, unsigned long num);
d65be0f
-void *_realloc_array(void *ptr, unsigned int size, unsigned long num);
d65be0f
+void *_realloc_array(void *ptr, unsigned int size, size_t num);
d65be0f
 const char *find_filename_suffix(const char *fn, int fn_len, int *len_ptr);
d65be0f
 uint32 fuzzy_distance(const char *s1, int len1, const char *s2, int len2);
d65be0f
 struct bitbag *bitbag_create(int max_ndx);