mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-02-21 19:02:25 +00:00
Ensure disk names follow the disk name regex
Currently disk names do not follow the (regex) /^[fhv]d[a-z]+[0-9]*$/ completely and hence one can assign disk names like vd2 etc. This patch ensures that the disk names follow the regex mentioned. This patch also adds a testcase. Signed-off-by: Nitesh Konkar <nitkon12@linux.vnet.ibm.com>
This commit is contained in:
parent
2dc1cf19db
commit
5729746543
@ -563,7 +563,7 @@ int virDiskNameParse(const char *name, int *disk, int *partition)
|
||||
}
|
||||
}
|
||||
|
||||
if (!ptr)
|
||||
if (!ptr || !c_islower(*ptr))
|
||||
return -1;
|
||||
|
||||
for (i = 0; *ptr; i++) {
|
||||
|
@ -37,7 +37,8 @@ static struct testDiskName diskNamesPart[] = {
|
||||
};
|
||||
|
||||
static const char* diskNamesInvalid[] = {
|
||||
"sda00", "sda01", "sdb-1"
|
||||
"sda00", "sda01", "sdb-1",
|
||||
"vd2"
|
||||
};
|
||||
|
||||
static int
|
||||
|
Loading…
x
Reference in New Issue
Block a user