linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] btrfs-progs: don't overrun "answer" array in cmds-chunk.c
@ 2013-08-06  2:52 Eric Sandeen
  2013-08-06  3:17 ` Miao Xie
  2013-08-06  3:57 ` Zach Brown
  0 siblings, 2 replies; 6+ messages in thread
From: Eric Sandeen @ 2013-08-06  2:52 UTC (permalink / raw)
  To: linux-btrfs; +Cc: Miao Xie

If an array is 5 chars in size:

       char answer[5];

and we write the 6th char (counting from 0)...

       answer[5] = '\0';

we get problems:

cmds-chunk.c: In function 'ask_user.clone.0':
cmds-chunk.c:1343: warning: array subscript is above array bounds

Fix it...

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
---


diff --git a/cmds-chunk.c b/cmds-chunk.c
index 03314de..7c3257c 100644
--- a/cmds-chunk.c
+++ b/cmds-chunk.c
@@ -1340,7 +1340,7 @@ again:
 		}
 		i++;
 	}
-	answer[5] = '\0';
+	answer[4] = '\0';
 	__fpurge(stdin);
 
 	if (strlen(answer) == 0) {


^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2013-08-06 18:49 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-08-06  2:52 [PATCH] btrfs-progs: don't overrun "answer" array in cmds-chunk.c Eric Sandeen
2013-08-06  3:17 ` Miao Xie
2013-08-06  3:57 ` Zach Brown
2013-08-06  4:03   ` Eric Sandeen
2013-08-06  5:57   ` Miao Xie
2013-08-06 18:49     ` Zach Brown

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).