From: James Simmons Date: Fri, 27 Jun 2025 19:53:24 +0000 (-0400) Subject: LU-19140 utils: sep in yaml_fill_scalar_data can be '\0' X-Git-Url: https://git.whamcloud.com/?a=commitdiff_plain;h=509a3f560a16f9d3643667d89843faec5c054428;p=fs%2Flustre-release.git LU-19140 utils: sep in yaml_fill_scalar_data can be '\0' While testing lnetctl import a corner case bug was exposed. For yaml_fill_scalar_data() the variable sep can be set to '\0' which when later we can strchr to find the newline will fail since it thinks its already at the end of the string. Instead do the search for the newline after sep has restored ':' at its start and skipped the whitespaces. Test-Parameters: trivial testlist=sanity-lnet Fixes: 8f64231185a ("LU-9680 utils: fix nested attribute handling in liblnetconfig") Change-Id: Ibcf03616777feca58599d816265947f6de27c5b8 Signed-off-by: James Simmons Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/59965 Reviewed-by: Chris Horn Reviewed-by: Frank Sehr Reviewed-by: Oleg Drokin Tested-by: jenkins Tested-by: Maloo --- diff --git a/lnet/utils/lnetconfig/liblnetconfig_netlink.c b/lnet/utils/lnetconfig/liblnetconfig_netlink.c index 7949132..96dbb58 100644 --- a/lnet/utils/lnetconfig/liblnetconfig_netlink.c +++ b/lnet/utils/lnetconfig/liblnetconfig_netlink.c @@ -1387,7 +1387,7 @@ static int yaml_fill_scalar_data(struct nl_msg *msg, } if (fmt & LNKF_MAPPING && sep) { - char *end = strchr(sep, '\n'); + char *end; int len; /* restore ':' */ @@ -1396,6 +1396,7 @@ static int yaml_fill_scalar_data(struct nl_msg *msg, while (isspace(*sep)) ++sep; + end = strchr(sep, '\n'); len = end ? end - sep : strlen(sep); if (len <= 0) goto nla_put_failure;