mirror of
git://sourceware.org/git/lvm2.git
synced 2024-12-21 13:34:40 +03:00
toolcontext: fix double free (core dumped) issue
How to trigger:
```
~ # export LVM_SYSTEM_DIR=_
~ # pvscan
No matching physical volumes found
double free or corruption (!prev)
Aborted (core dumped)
```
when LVM_SYSTEM_DIR is empty, _load_config_file() won't be called.
when LVM_SYSTEM_DIR is not empty, cfl->cft links into cmd->config_files
by _load_config_file()@lib/commands/toolcontext.c
core dumped code: _destroy_config()@lib/commands/toolcontext.c
```
/* CONFIG_FILE/CONFIG_MERGED_FILES */
if ((cft = remove_config_tree_by_source(cmd, CONFIG_MERGED_FILES)))
config_destroy(cft);
else if ((cft = remove_config_tree_by_source(cmd, CONFIG_FILE)))
config_destroy(cft); <=== first free the cft
dm_list_iterate_items(cfl, &cmd->config_files)
config_destroy(cfl->cft); <=== double free the cft
```
Fixes: c43f2f8ae0
Signed-off-by: Heming Zhao <heming.zhao@suse.com>
This commit is contained in:
parent
66daedc6d2
commit
db22a389cf
@ -966,8 +966,13 @@ static void _destroy_config(struct cmd_context *cmd)
|
|||||||
/* CONFIG_FILE/CONFIG_MERGED_FILES */
|
/* CONFIG_FILE/CONFIG_MERGED_FILES */
|
||||||
if ((cft = remove_config_tree_by_source(cmd, CONFIG_MERGED_FILES)))
|
if ((cft = remove_config_tree_by_source(cmd, CONFIG_MERGED_FILES)))
|
||||||
config_destroy(cft);
|
config_destroy(cft);
|
||||||
else if ((cft = remove_config_tree_by_source(cmd, CONFIG_FILE)))
|
else if ((cft = remove_config_tree_by_source(cmd, CONFIG_FILE))) {
|
||||||
|
dm_list_iterate_items(cfl, &cmd->config_files) {
|
||||||
|
if (cfl->cft == cft)
|
||||||
|
dm_list_del(&cfl->list);
|
||||||
|
}
|
||||||
config_destroy(cft);
|
config_destroy(cft);
|
||||||
|
}
|
||||||
|
|
||||||
dm_list_iterate_items(cfl, &cmd->config_files)
|
dm_list_iterate_items(cfl, &cmd->config_files)
|
||||||
config_destroy(cfl->cft);
|
config_destroy(cfl->cft);
|
||||||
|
Loading…
Reference in New Issue
Block a user