]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/commitdiff
xfs_repair: fix array overrun in do_inode_prefetch
authorEric Sandeen <sandeen@redhat.com>
Thu, 6 Mar 2014 23:33:04 +0000 (10:33 +1100)
committerDave Chinner <david@fromorbit.com>
Thu, 6 Mar 2014 23:33:04 +0000 (10:33 +1100)
Coverity spotted this:

do_inode_prefetch() does a while loop, creating queues:

        for (i = 0; i < thread_count; i++) {
...
create_work_queue(&queues[i], mp, 1);
...
}

and then does this to wait for them all to complete:

for (; i >= 0; i--)
destroy_work_queue(&queues[i]);

But we leave the first for loop with (i == thread_coun)t, and
the second one will try to index queues[] one past the end.

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 0f9e3fe50566c283e8cbfcc3620d0e790b4039a3..e47a48e398d8e9fca036d76fa0e9bd86dd6c6fad 100644 (file)
@@ -995,7 +995,7 @@ do_inode_prefetch(
        /*
         * wait for workers to complete
         */
-       for (; i >= 0; i--)
+       while (i--)
                destroy_work_queue(&queues[i]);
        free(queues);
 }