From 00aede1e95a08e413825598efcd1a8cece49f20a Mon Sep 17 00:00:00 2001 From: Alexandre Ioffe Date: Tue, 11 Oct 2022 17:53:20 -0700 Subject: [PATCH] EX-6130 lipe: s_volume_name not NUL terminated s_volume_name field stores string, but the field may have no termination NUL if the string size equal the size of the field. Therefore on some target systems the definition of struct ext2_super_block s_volume_name in /usr/include/ext2fs/ext2_fs.h may have attribute "nonstring". In such case it conflicts with calls which require NUL terminated string. The fix replaces NUL-terminated string calls by calls with limited string size (e.g. strlen() -> strnlen()) Signed-off-by: Alexandre Ioffe Change-Id: Ieb1921a289328a8f9bfae9bb658c6c74f8ec43b7 Reviewed-on: https://review.whamcloud.com/c/ex/lustre-release/+/48829 Tested-by: jenkins Tested-by: Maloo Reviewed-by: Andreas Dilger --- lipe/src/lipe_scan3/ls3_scan.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lipe/src/lipe_scan3/ls3_scan.c b/lipe/src/lipe_scan3/ls3_scan.c index 8b9f13d..13361fa 100644 --- a/lipe/src/lipe_scan3/ls3_scan.c +++ b/lipe/src/lipe_scan3/ls3_scan.c @@ -1313,7 +1313,8 @@ retry_open: goto out; } - li.li_device_name = xstrdup((const char *)fs->super->s_volume_name); + li.li_device_name = xstrndup((const char *)fs->super->s_volume_name, + sizeof(fs->super->s_volume_name)); LS3_DEBUG_S(li.li_device_name); li.li_scm_device_name = scm_from_latin1_string(li.li_device_name); -- 1.8.3.1