xfs
[Top] [All Lists]

[PATCH 14/14] xfs_db: don't use invalid index in ring_f

To: xfs@xxxxxxxxxxx
Subject: [PATCH 14/14] xfs_db: don't use invalid index in ring_f
From: Eric Sandeen <sandeen@xxxxxxxxxx>
Date: Tue, 8 Apr 2014 18:25:04 -0500
Delivered-to: xfs@xxxxxxxxxxx
In-reply-to: <1396999504-13769-1-git-send-email-sandeen@xxxxxxxxxx>
References: <1396999504-13769-1-git-send-email-sandeen@xxxxxxxxxx>
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@xxxxxxxxxx>
---
 db/io.c |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)

diff --git a/db/io.c b/db/io.c
index 9a787c8..6aba54e 100644
--- 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;
 
-- 
1.7.1

<Prev in Thread] Current Thread [Next in Thread>