mirror of
git://sourceware.org/git/lvm2.git
synced 2025-01-03 05:18:29 +03:00
libdm: unmangle dm UUIDs on dm ioctl return
This commit is contained in:
parent
7e71ecbaf6
commit
8dccbae35e
@ -1571,44 +1571,48 @@ static const char *_sanitise_message(char *message)
|
|||||||
return sanitised_message;
|
return sanitised_message;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int _do_dm_ioctl_unmangle_name(char *name)
|
static int _do_dm_ioctl_unmangle_string(char *str, const char *str_name,
|
||||||
|
char *buf, size_t buf_size,
|
||||||
|
dm_string_mangling_t mode)
|
||||||
{
|
{
|
||||||
dm_string_mangling_t mode = dm_get_name_mangling_mode();
|
|
||||||
char buf[DM_NAME_LEN];
|
|
||||||
int r;
|
int r;
|
||||||
|
|
||||||
if (mode == DM_STRING_MANGLING_NONE)
|
if (mode == DM_STRING_MANGLING_NONE)
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
if (!check_multiple_mangled_string_allowed(name, "name", mode))
|
if (!check_multiple_mangled_string_allowed(str, str_name, mode))
|
||||||
return_0;
|
return_0;
|
||||||
|
|
||||||
if ((r = unmangle_string(name, "name", DM_NAME_LEN, buf, sizeof(buf), mode)) < 0) {
|
if ((r = unmangle_string(str, str_name, strlen(str), buf, buf_size, mode)) < 0) {
|
||||||
log_debug("_do_dm_ioctl_unmangle_name: failed to "
|
log_debug("_do_dm_ioctl_unmangle_string: failed to "
|
||||||
"unmangle \"%s\"", name);
|
"unmangle %s \"%s\"", str_name, str);
|
||||||
return 0;
|
return 0;
|
||||||
} else if (r)
|
} else if (r)
|
||||||
memcpy(name, buf, strlen(buf) + 1);
|
memcpy(str, buf, strlen(buf) + 1);
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int _dm_ioctl_unmangle_names(int type, struct dm_ioctl *dmi)
|
static int _dm_ioctl_unmangle_names(int type, struct dm_ioctl *dmi)
|
||||||
{
|
{
|
||||||
|
char buf[DM_NAME_LEN];
|
||||||
struct dm_names *names;
|
struct dm_names *names;
|
||||||
unsigned next = 0;
|
unsigned next = 0;
|
||||||
char *name;
|
char *name;
|
||||||
int r = 1;
|
int r = 1;
|
||||||
|
|
||||||
if ((name = dmi->name))
|
if ((name = dmi->name))
|
||||||
r = _do_dm_ioctl_unmangle_name(name);
|
r = _do_dm_ioctl_unmangle_string(name, "name", buf, sizeof(buf),
|
||||||
|
dm_get_name_mangling_mode());
|
||||||
|
|
||||||
if (type == DM_DEVICE_LIST &&
|
if (type == DM_DEVICE_LIST &&
|
||||||
((names = ((struct dm_names *) ((char *)dmi + dmi->data_start)))) &&
|
((names = ((struct dm_names *) ((char *)dmi + dmi->data_start)))) &&
|
||||||
names->dev) {
|
names->dev) {
|
||||||
do {
|
do {
|
||||||
names = (struct dm_names *)((char *) names + next);
|
names = (struct dm_names *)((char *) names + next);
|
||||||
r = _do_dm_ioctl_unmangle_name(names->name);
|
r = _do_dm_ioctl_unmangle_string(names->name, "name",
|
||||||
|
buf, sizeof(buf),
|
||||||
|
dm_get_name_mangling_mode());
|
||||||
next = names->next;
|
next = names->next;
|
||||||
} while (next);
|
} while (next);
|
||||||
}
|
}
|
||||||
@ -1616,6 +1620,18 @@ static int _dm_ioctl_unmangle_names(int type, struct dm_ioctl *dmi)
|
|||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int _dm_ioctl_unmangle_uuids(int type, struct dm_ioctl *dmi)
|
||||||
|
{
|
||||||
|
char buf[DM_UUID_LEN];
|
||||||
|
char *uuid = dmi->uuid;
|
||||||
|
|
||||||
|
if (uuid)
|
||||||
|
return _do_dm_ioctl_unmangle_string(uuid, "UUID", buf, sizeof(buf),
|
||||||
|
dm_get_name_mangling_mode());
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
static struct dm_ioctl *_do_dm_ioctl(struct dm_task *dmt, unsigned command,
|
static struct dm_ioctl *_do_dm_ioctl(struct dm_task *dmt, unsigned command,
|
||||||
unsigned buffer_repeat_count,
|
unsigned buffer_repeat_count,
|
||||||
unsigned retry_repeat_count,
|
unsigned retry_repeat_count,
|
||||||
@ -1746,6 +1762,9 @@ static struct dm_ioctl *_do_dm_ioctl(struct dm_task *dmt, unsigned command,
|
|||||||
if (!_dm_ioctl_unmangle_names(dmt->type, dmi))
|
if (!_dm_ioctl_unmangle_names(dmt->type, dmi))
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
|
if (!_dm_ioctl_unmangle_uuids(dmt->type, dmi))
|
||||||
|
goto error;
|
||||||
|
|
||||||
#else /* Userspace alternative for testing */
|
#else /* Userspace alternative for testing */
|
||||||
#endif
|
#endif
|
||||||
return dmi;
|
return dmi;
|
||||||
|
Loading…
Reference in New Issue
Block a user