diff mbox series

[2/2] xfs_db: fix a complaint about a printf buffer overrun

Message ID 165176665092.246897.6105158987030874479.stgit@magnolia (mailing list archive)
State Accepted
Headers show
Series xfsprogs: random fixes | expand

Commit Message

Darrick J. Wong May 5, 2022, 4:04 p.m. UTC
From: Darrick J. Wong <djwong@kernel.org>

gcc 11 warns that stack_f doesn't allocate a sufficiently large buffer
to hold the printf output.  I don't think the io cursor stack is really
going to grow to 4 billion levels deep, but let's fix this anyway.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
---
 db/io.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Eric Sandeen May 5, 2022, 7:34 p.m. UTC | #1
On 5/5/22 11:04 AM, Darrick J. Wong wrote:
> From: Darrick J. Wong <djwong@kernel.org>
> 
> gcc 11 warns that stack_f doesn't allocate a sufficiently large buffer
> to hold the printf output.  I don't think the io cursor stack is really
> going to grow to 4 billion levels deep, but let's fix this anyway.
> 
> Signed-off-by: Darrick J. Wong <djwong@kernel.org>

Reviewed-by: Eric Sandeen <sandeen@redhat.com>
Christoph Hellwig May 10, 2022, 9:38 a.m. UTC | #2
On Thu, May 05, 2022 at 09:04:10AM -0700, Darrick J. Wong wrote:
> From: Darrick J. Wong <djwong@kernel.org>
> 
> gcc 11 warns that stack_f doesn't allocate a sufficiently large buffer
> to hold the printf output.  I don't think the io cursor stack is really
> going to grow to 4 billion levels deep, but let's fix this anyway.

Looks good:

Reviewed-by: Christoph Hellwig <hch@lst.de>
diff mbox series

Patch

diff --git a/db/io.c b/db/io.c
index 98f4e605..bfc86cc4 100644
--- a/db/io.c
+++ b/db/io.c
@@ -638,7 +638,7 @@  stack_f(
 	char	**argv)
 {
 	int	i;
-	char	tagbuf[8];
+	char	tagbuf[14];
 
 	for (i = iocur_sp; i > 0; i--) {
 		snprintf(tagbuf, sizeof(tagbuf), "%d: ", i);