From 1db90b29ad676c2cf1888ef5a7c623161ff23bf9 Mon Sep 17 00:00:00 2001 From: Andreas Dilger Date: Wed, 2 Jan 2019 15:12:11 -0700 Subject: [PATCH 1/1] LU-11834 llite: fix temporary instance buffer size The formatting of the cfg_instance variable was changed in LU-11809 to always use a fixed "%016llu" format, but the temporary buffer allocations for the instance string were not changed to match the printed value. This results in string truncation in some situations. Change the temp buffer size to always have 16 bytes for the instance instead of using sizeof(cfg_instance). Fixes: cd294a1255 ("LU-11809 llite: don't use %p for cfg_instance") Test-Parameters: trivial Signed-off-by: Andreas Dilger Change-Id: I5eca99afa2787cc57e739489b252b12af68cab07 Reviewed-on: https://review.whamcloud.com/33951 Tested-by: Jenkins Tested-by: Maloo Reviewed-by: Sebastien Buisson Reviewed-by: James Simmons Reviewed-by: Oleg Drokin --- lustre/llite/llite_lib.c | 2 +- lustre/obdclass/obd_config.c | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/lustre/llite/llite_lib.c b/lustre/llite/llite_lib.c index a7e8672..34f1627 100644 --- a/lustre/llite/llite_lib.c +++ b/lustre/llite/llite_lib.c @@ -1016,7 +1016,7 @@ int ll_fill_super(struct super_block *sb, struct vfsmount *mnt) char *profilenm = get_profile_name(sb); struct config_llog_instance *cfg; /* %p for void* in printf needs 16+2 characters: 0xffffffffffffffff */ - const int instlen = sizeof(cfg->cfg_instance) * 2 + 2; + const int instlen = 16 + 2; unsigned long cfg_instance = ll_get_cfg_instance(sb); char name[MAX_STRING_SIZE]; int md_len = 0; diff --git a/lustre/obdclass/obd_config.c b/lustre/obdclass/obd_config.c index 1c02fd6..869e64c 100644 --- a/lustre/obdclass/obd_config.c +++ b/lustre/obdclass/obd_config.c @@ -1712,8 +1712,7 @@ int class_config_llog_handler(const struct lu_env *env, if (cfg->cfg_instance && lcfg->lcfg_command != LCFG_SPTLRPC_CONF && LUSTRE_CFG_BUFLEN(lcfg, 0) > 0) { - inst_len = LUSTRE_CFG_BUFLEN(lcfg, 0) + - sizeof(cfg->cfg_instance) * 2 + 4; + inst_len = LUSTRE_CFG_BUFLEN(lcfg, 0) + 16 + 4; OBD_ALLOC(inst_name, inst_len); if (inst_name == NULL) GOTO(out, rc = -ENOMEM); -- 1.8.3.1