From 659495cb58f2eeb29784a37dcb1df7b5868708e4 Mon Sep 17 00:00:00 2001 From: Bobi Jam Date: Wed, 19 Apr 2023 22:19:53 +0800 Subject: [PATCH] LU-16768 lfs: copy optarg string other than using it directly Copy optarg string for fp_format_printf_str lest it be messed later. Lustre-change: https://review.whamcloud.com/50733 Lustre-commit: 75db98cef3df8f9a0e1b6e7a5150f3c332e6167b Signed-off-by: Bobi Jam Change-Id: Ib32883d3261ae921adf0fdd7b05bcbf728de7557 Reviewed-on: https://review.whamcloud.com/c/ex/lustre-release/+/50690 Tested-by: jenkins Tested-by: Andreas Dilger Reviewed-by: Andreas Dilger --- lustre/utils/lfs.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lustre/utils/lfs.c b/lustre/utils/lfs.c index 3fedb27..59b8095 100644 --- a/lustre/utils/lfs.c +++ b/lustre/utils/lfs.c @@ -5658,7 +5658,7 @@ err_free: case 'P': /* we always print, this option is a no-op */ break; case LFS_PRINTF_OPT: - param.fp_format_printf_str = optarg; + param.fp_format_printf_str = strdup(optarg); break; case LFS_PROJID_OPT: rc = name2projid(¶m.fp_projid, optarg); @@ -5825,6 +5825,9 @@ err: if (param.fp_mdt_uuid && param.fp_num_alloc_mdts) free(param.fp_mdt_uuid); + if (param.fp_format_printf_str) + free(param.fp_format_printf_str); + return ret; } -- 1.8.3.1