config: fix value trunction when reading int64 configurations
PATCH 1/2 config: fix value trunction when reading int64 configurations
Use int64_t to prevent truncation of the parsed value.
Signed-off-by Ming-Hung Tsai <[email protected]>
--- lib/config/config.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
lib/config/config.c +1 -1
@@ -1372,7 +1372,7 @@ int64_t find_config_tree_int64(struct cmd_context *cmd, int id, struct profile *const cfg_def_item_t *item =cfg_def_get_item_p (id);char path[CFG_PATH_MAX_LEN ];int profile_applied; -int i64; +int64_t i64; profile_applied =_apply_local_profile (cmd, profile);_cfg_def_make_path (path,sizeof (path), item->id, item,0 );
Signature · 1 line
2.47.0
PATCH 2/2 cache: fix integer conversion error in parsing cache_pool_max_chunks
The allocation/cache_pool_max_chunks config is read as an int32_t, then converted to uint64_t. If the value in lvm.conf exceeds INT32_MAX, conversion to uint64_t results in truncation followed by sign extension, causing the original unsigned representation to be lost. For example, a config value of 6442450944 is converted to 18446744071562067968.
This fix preserves the original u64 value from the parser. Further adjustments should be applied to fit dm-cache's metadata limits.
Signed-off-by Ming-Hung Tsai <[email protected]>
--- lib/config/config.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
lib/config/config.c +1 -1
@@ -2555,7 +2555,7 @@ uint64_t get_default_allocation_cache_pool_max_chunks_CFG(struct cmd_context *cm* newer targets may scale better. */ uint64_t default_max_chunks =DEFAULT_CACHE_POOL_MAX_CHUNKS ; -uint64_t max_chunks =find_config_tree_int (cmd, allocation_cache_pool_max_chunks_CFG, profile); +uint64_t max_chunks =find_config_tree_int64 (cmd, allocation_cache_pool_max_chunks_CFG, profile);if (!max_chunks) max_chunks = default_max_chunks;
Signature · 1 line
2.47.0