Whamcloud - gitweb
LU-11834 llite: fix temporary instance buffer size 51/33951/2
authorAndreas Dilger <adilger@whamcloud.com>
Wed, 2 Jan 2019 22:12:11 +0000 (15:12 -0700)
committerOleg Drokin <green@whamcloud.com>
Wed, 16 Jan 2019 07:08:27 +0000 (07:08 +0000)
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 <adilger@whamcloud.com>
Change-Id: I5eca99afa2787cc57e739489b252b12af68cab07
Reviewed-on: https://review.whamcloud.com/33951
Tested-by: Jenkins
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Sebastien Buisson <sbuisson@ddn.com>
Reviewed-by: James Simmons <uja.ornl@yahoo.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
lustre/llite/llite_lib.c
lustre/obdclass/obd_config.c

index a7e8672..34f1627 100644 (file)
@@ -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;
index 1c02fd6..869e64c 100644 (file)
@@ -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);