]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/commitdiff
xfs_db: don't use invalid index in ring_f
authorEric Sandeen <sandeen@redhat.com>
Mon, 14 Apr 2014 06:13:47 +0000 (16:13 +1000)
committerDave Chinner <david@fromorbit.com>
Mon, 14 Apr 2014 06:13:47 +0000 (16:13 +1000)
ring_f() tests for an invalid index which would overrun the
iocur_ring[] array and warns, but then uses it anyway.

Return immediately if it's out of bounds.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
db/io.c

diff --git a/db/io.c b/db/io.c
index 89e60305bf9aa6f889853f38185f6a2e7062fd05..5eb61d920e2fd4ad45d1b599b613b395af47e026 100644 (file)
--- a/db/io.c
+++ b/db/io.c
@@ -358,8 +358,10 @@ ring_f(
        }
 
        index = (int)strtoul(argv[1], NULL, 0);
-       if (index < 0 || index >= RING_ENTRIES)
+       if (index < 0 || index >= RING_ENTRIES) {
                dbprintf(_("invalid entry: %d\n"), index);
+               return 0;
+       }
 
        ring_current = index;