]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/commitdiff
xfs_repair: don't let bplist index go negative in prefetch
authorEric Sandeen <sandeen@redhat.com>
Tue, 20 May 2014 08:30:44 +0000 (18:30 +1000)
committerDave Chinner <david@fromorbit.com>
Tue, 20 May 2014 08:30:44 +0000 (18:30 +1000)
After:

bbd3275 repair: don't unlock prefetch tree to read discontig buffers

Coverity spotted that it's possible for us to arrive at the loop
below with num == 1, and then we decrement it to 0, and try to
index bplist[num-1].

I think this was possible before the change, i.e. it's probably
not a regression.

Fix this by not trying to shrink the window unless we have
more than one buffer in the array.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
repair/prefetch.c

index 4595310a269975babed500a96ef7216688e9f440..65f8456619afe0062bff07e43b43ac8f9621f8a8 100644 (file)
@@ -505,7 +505,7 @@ pf_batch_read(
                first_off = LIBXFS_BBTOOFF64(XFS_BUF_ADDR(bplist[0]));
                last_off = LIBXFS_BBTOOFF64(XFS_BUF_ADDR(bplist[num-1])) +
                        XFS_BUF_SIZE(bplist[num-1]);
-               while (last_off - first_off > pf_max_bytes) {
+               while (num > 1 && last_off - first_off > pf_max_bytes) {
                        num--;
                        last_off = LIBXFS_BBTOOFF64(XFS_BUF_ADDR(bplist[num-1])) +
                                XFS_BUF_SIZE(bplist[num-1]);