Fix a potential crash when trying to find a better block match.
authorWayne Davison <wayned@samba.org>
Fri, 22 Apr 2011 18:31:29 +0000 (11:31 -0700)
committerWayne Davison <wayned@samba.org>
Fri, 22 Apr 2011 23:06:06 +0000 (16:06 -0700)
match.c

diff --git a/match.c b/match.c
index 9da18a7..f327fd3 100644 (file)
--- a/match.c
+++ b/match.c
@@ -239,8 +239,9 @@ static void hash_search(int f,struct sum_struct *s,
                                        aligned_offset += s->blength;
                                        aligned_i++;
                                }
-                               if (offset == aligned_offset
-                                || (sum == 0 && l == s->blength && aligned_offset + l <= len)) {
+                               if ((offset == aligned_offset
+                                 || (sum == 0 && l == s->blength && aligned_offset + l <= len))
+                                && aligned_i < s->count) {
                                        if (i != aligned_i) {
                                                if (sum != s->sums[aligned_i].sum1
                                                 || l != s->sums[aligned_i].len