Include backup in map_ptr() to avoid backing up when reading.
authorWayne Davison <wayned@samba.org>
Sat, 15 Jan 2011 19:16:49 +0000 (11:16 -0800)
committerWayne Davison <wayned@samba.org>
Sat, 15 Jan 2011 19:16:49 +0000 (11:16 -0800)
match.c

diff --git a/match.c b/match.c
index cbb6fe2..f8a1a8f 100644 (file)
--- a/match.c
+++ b/match.c
@@ -257,7 +257,11 @@ static void hash_search(int f,struct sum_struct *s,
                                                         * in the sender's file, we'll output enough literal data
                                                         * to re-align with the basis file, and get back to seeking
                                                         * instead of writing. */
-                                                       map = (schar *)map_ptr(buf, aligned_offset, l);
+                                                       backup = (int32)(aligned_offset - last_match);
+                                                       if (backup < 0)
+                                                               backup = 0;
+                                                       map = (schar *)map_ptr(buf, aligned_offset - backup, l + backup)
+                                                           + backup;
                                                        sum = get_checksum1((char *)map, l);
                                                        if (sum != s->sums[i2].sum1)
                                                                break;