bcache: Use scnprintf() for avoiding potential buffer overflow
PATCH 1/1 bcache: Use scnprintf() for avoiding potential buffer overflow
Since snprintf() returns the would-be-output size instead of the actual output size, the succeeding calls may go beyond the given buffer limit. Fix it by replacing with scnprintf().
--- drivers/md/bcache/sysfs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/md/bcache/sysfs.c +1 -1
@@ -154,7 +154,7 @@ static ssize_t bch_snprint_string_list(char *buf,size_t i;for (i =0 ; list[i]; i++) - out +=snprintf (out, buf + size - out, + out +=scnprintf (out, buf + size - out, i == selected ?"[%s] " :"%s " , list[i]); out[-1 ] ='\n' ;
Signature · 1 line
2.16.4
Quoted 6 lines · Takashi Iwai
Since
snprintf()returns the would-be-output size instead of the actual output size, the succeeding calls may go beyond the given buffer limit. Fix it by replacing withscnprintf().Signed-off-by Takashi Iwai <[email protected]>
A gentle reminder for this forgotten patch.
Let me know if any further changes are needed.
thanks,
Takashi
Quoted 20 lines
--- drivers/md/bcache/sysfs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/md/bcache/sysfs.c +1
-1@@ -154,7 +154,7 @@ static ssize_t bch_snprint_string_list(char *buf,size_t i;for (i =0 ; list[i]; i++) - out +=snprintf (out, buf + size - out, + out +=scnprintf (out, buf + size - out, i == selected ?"[%s] " :"%s " , list[i]); out[-1 ] ='\n' ;Signature · 1 line
2.16.4
Quoted 12 lines · Takashi Iwai
Quoted 6 lines · Takashi Iwai
Since
snprintf()returns the would-be-output size instead of the actual output size, the succeeding calls may go beyond the given buffer limit. Fix it by replacing withscnprintf().Signed-off-by Takashi Iwai <[email protected]>A gentle reminder for this forgotten patch.
Let me know if any further changes are needed.
Hi Takashi,
This is in my for-next list already. Sorry for not reply you yet, just busy on the testing with combined with md raid backend.
Thanks.
Coly Li
Quoted 20 lines
Quoted 20 lines
--- drivers/md/bcache/sysfs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/md/bcache/sysfs.c +1
-1@@ -154,7 +154,7 @@ static ssize_t bch_snprint_string_list(char *buf,size_t i;for (i =0 ; list[i]; i++) - out +=snprintf (out, buf + size - out, + out +=scnprintf (out, buf + size - out, i == selected ?"[%s] " :"%s " , list[i]); out[-1 ] ='\n' ;Signature · 1 line
2.16.4
Signature · 1 line
Coly Li
Quoted 11 lines · Coly Li
Quoted 9 lines · Takashi Iwai
Quoted 6 lines · Takashi Iwai
Since
snprintf()returns the would-be-output size instead of the actual output size, the succeeding calls may go beyond the given buffer limit. Fix it by replacing withscnprintf().Signed-off-by Takashi Iwai <[email protected]>
Quoted 8 lines
Quoted 3 lines
A gentle reminder for this forgotten patch.
Let me know if any further changes are needed.Hi Takashi,
This is in my for-next list already. Sorry for not reply you yet, just busy on the testing with combined with md raid backend.
OK, thanks. I just wondered because it didn't appear on linux-next, either.
Takashi
Quoted 31 lines
Thanks.
Coly Li
Quoted 20 lines
Quoted 20 lines
--- drivers/md/bcache/sysfs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/md/bcache/sysfs.c +1
-1@@ -154,7 +154,7 @@ static ssize_t bch_snprint_string_list(char *buf,size_t i;for (i =0 ; list[i]; i++) - out +=snprintf (out, buf + size - out, + out +=scnprintf (out, buf + size - out, i == selected ?"[%s] " :"%s " , list[i]); out[-1 ] ='\n' ;Signature · 1 line
2.16.4Signature · 1 line
Coly Li
Quoted 17 lines · Takashi Iwai
Quoted 15 lines · Coly Li
Quoted 12 lines · Takashi Iwai
Quoted 6 lines · Takashi Iwai
Since
snprintf()returns the would-be-output size instead of the actual output size, the succeeding calls may go beyond the given buffer limit. Fix it by replacing withscnprintf().Signed-off-by Takashi Iwai <[email protected]>A gentle reminder for this forgotten patch.
Let me know if any further changes are needed.
Quoted 7 lines
Quoted 4 lines
Hi Takashi,
This is in my for-next list already. Sorry for not reply you yet, just busy on the testing with combined with md raid backend.
OK, thanks. I just wondered because it didn't appear on linux-next, either.
I don't submit the patch set to Jens yet, because my local testing not finished yet. Hopefully it may finish in next 2 days.
Signature · 1 line
Coly Li