The "label" field in "struct bch_sb" is not guaranteed to be null-terminated. Therefore, juding the first character is safer than using strlen().
This patch fixes issue koverstreet/bcachefs-tools#341. Signed-off-by: [email protected] <[email protected]> --- fs/bcachefs/super-io.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/bcachefs/super-io.c b/fs/bcachefs/super-io.c index c83bd3dedb1b..c612319ba901 100644 --- a/fs/bcachefs/super-io.c +++ b/fs/bcachefs/super-io.c @@ -1322,7 +1322,7 @@ void bch2_sb_to_text(struct printbuf *out, struct bch_sb *sb, prt_printf(out, "Device index:\t%u\n", sb->dev_idx); prt_printf(out, "Label:\t"); - if (!strlen(sb->label)) + if (!sb->label[0]) prt_printf(out, "(none)"); else prt_printf(out, "%.*s", (int) sizeof(sb->label), sb->label); -- 2.47.0
