]> git.neil.brown.name Git - LaFS.git/commitdiff
walk_index: fix "found end of addresses" detection.
authorNeilBrown <neilb@suse.de>
Wed, 23 Jun 2010 01:41:21 +0000 (11:41 +1000)
committerNeilBrown <neilb@suse.de>
Wed, 23 Jun 2010 02:48:48 +0000 (12:48 +1000)
As phys was being overloaded slightly, this was broken.

Signed-off-by: NeilBrown <neilb@suse.de>
modify.c

index 34712b83ab9676eb661234685855e09ef2a4ba77..d871d397194692aeaa6aefd77163f2bff9c586c9 100644 (file)
--- a/modify.c
+++ b/modify.c
@@ -729,10 +729,11 @@ static u32 walk_index(u32 addr, char **bufp, int len, struct block *uninc,
         * Entries are 10 bytes: 6 byte dev address, 4 byte file address.
         */
        char *buf = *bufp;
+       int found_end = 0;
 
        handle(data, addr, 0); /* initialise */
 
-       while (len >= 10 || uninc != NULL) {
+       while ((len >= 10 && !found_end) || uninc != NULL) {
                unsigned long addr = 0;
                u64 phys = 0;
 
@@ -740,6 +741,8 @@ static u32 walk_index(u32 addr, char **bufp, int len, struct block *uninc,
                        phys = decode48(buf);
                        addr = decode32(buf);
                        len -= 10;
+                       if (phys == 0)
+                               found_end = 1;
                }
 
                while (uninc &&
@@ -762,8 +765,6 @@ static u32 walk_index(u32 addr, char **bufp, int len, struct block *uninc,
                        *bufp = buf - 10;
                        return 0;
                }
-               if (phys == 0 && uninc == NULL)
-                       break;
        }
        handle(data, 0, ~(u64)0); /* finalise */
        return 1;