Re: [PATCH] btrfs-progs: don't overrun answer array in cmds-chunk.c

2013-08-06 Thread Zach Brown
If you're in here, want to reimplement this thing in a few lines of scanf(%s) and strcasecmp()? I can give it a go if you don't want to. I think it is better that moving it to utils.c because the other commands may use it in the future. I disagree. Let's stick to only writing the code

[PATCH] btrfs-progs: don't overrun answer array in cmds-chunk.c

2013-08-05 Thread Eric Sandeen
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

Re: [PATCH] btrfs-progs: don't overrun answer array in cmds-chunk.c

2013-08-05 Thread Miao Xie
On mon, 05 Aug 2013 21:52:57 -0500, Eric Sandeen wrote: 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:

Re: [PATCH] btrfs-progs: don't overrun answer array in cmds-chunk.c

2013-08-05 Thread Zach Brown
On Mon, Aug 05, 2013 at 09:52:57PM -0500, Eric Sandeen wrote: If an array is 5 chars in size: char answer[5]; and we write the 6th char (counting from 0)... answer[5] = '\0'; *high fives* - answer[5] = '\0'; + answer[4] = '\0'; I went to see which way of

Re: [PATCH] btrfs-progs: don't overrun answer array in cmds-chunk.c

2013-08-05 Thread Eric Sandeen
On 8/5/13 10:57 PM, Zach Brown wrote: On Mon, Aug 05, 2013 at 09:52:57PM -0500, Eric Sandeen wrote: If an array is 5 chars in size: char answer[5]; and we write the 6th char (counting from 0)... answer[5] = '\0'; *high fives* -answer[5] = '\0'; +answer[4] =

Re: [PATCH] btrfs-progs: don't overrun answer array in cmds-chunk.c

2013-08-05 Thread Miao Xie
On Mon, 5 Aug 2013 20:57:57 -0700, Zach Brown wrote: On Mon, Aug 05, 2013 at 09:52:57PM -0500, Eric Sandeen wrote: If an array is 5 chars in size: char answer[5]; and we write the 6th char (counting from 0)... answer[5] = '\0'; *high fives* -answer[5] = '\0'; +