mirror of
https://github.com/libguestfs/libguestfs.git
synced 2026-03-21 22:53:37 +00:00
daemon: lvm: Pass device parameter of lvm_canonical_lv_name as PlainString.
All sorts of strings might be passed here hoping to make them canonical LV names. We cannot be sure that the strings passed will be devices which exist in the appliance.
This commit is contained in:
13
daemon/lvm.c
13
daemon/lvm.c
@@ -723,7 +723,18 @@ char *
|
||||
do_lvm_canonical_lv_name (const char *device)
|
||||
{
|
||||
char *canonical;
|
||||
int r = lv_canonical (device, &canonical);
|
||||
int r;
|
||||
|
||||
/* The device parameter is passed as PlainString because we can't
|
||||
* really be sure that the device name will exist (especially for
|
||||
* "/dev/mapper/..." names). Do some sanity checking on it here.
|
||||
*/
|
||||
if (!STRPREFIX (device, "/dev/")) {
|
||||
reply_with_error ("%s: not a device name", device);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
r = lv_canonical (device, &canonical);
|
||||
if (r == -1)
|
||||
return NULL;
|
||||
|
||||
|
||||
@@ -6002,7 +6002,7 @@ See also C<guestfs_pread>." };
|
||||
|
||||
{ defaults with
|
||||
name = "lvm_canonical_lv_name"; added = (1, 5, 24);
|
||||
style = RString (RDevice, "lv"), [String (Device, "lvname")], [];
|
||||
style = RString (RDevice, "lv"), [String (PlainString, "lvname")], [];
|
||||
tests = [
|
||||
InitBasicFSonLVM, IfAvailable "lvm2", TestResultString (
|
||||
[["lvm_canonical_lv_name"; "/dev/mapper/VG-LV"]], "/dev/VG/LV"), [];
|
||||
|
||||
Reference in New Issue
Block a user