mirror of
git://sourceware.org/git/lvm2.git
synced 2024-12-21 13:34:40 +03:00
libdm: better error reporting from dm_split_lvm_name
Report errors from all error paths correctly. Validate passed args before dereferencing them.
This commit is contained in:
parent
5d4f5873a9
commit
2a2487f02f
@ -95,13 +95,18 @@ static char *_unquote(char *component)
|
|||||||
int dm_split_lvm_name(struct dm_pool *mem, const char *dmname,
|
int dm_split_lvm_name(struct dm_pool *mem, const char *dmname,
|
||||||
char **vgname, char **lvname, char **layer)
|
char **vgname, char **lvname, char **layer)
|
||||||
{
|
{
|
||||||
if (mem && !(*vgname = dm_pool_strdup(mem, dmname))) {
|
if (!vgname || !lvname || !layer) {
|
||||||
log_error("Failed to duplicate dmname.");
|
log_error(INTERNAL_ERROR "dm_split_lvm_name: vgname, lvname nor layer could be NULL.");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!*vgname)
|
if (mem && (!dmname || !(*vgname = dm_pool_strdup(mem, dmname)))) {
|
||||||
|
log_error("Failed to duplicate lvm name.");
|
||||||
return 0;
|
return 0;
|
||||||
|
} else if (!*vgname) {
|
||||||
|
log_error("Missing lvm name for split.");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
_unquote(*layer = _unquote(*lvname = _unquote(*vgname)));
|
_unquote(*layer = _unquote(*lvname = _unquote(*vgname)));
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user