From: Nitesh Konkar Date: Wed, 15 Feb 2017 11:14:58 +0000 (+0530) Subject: Ensure disk names follow the disk name regex X-Git-Tag: CVE-2017-2635~100 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5729746543cf4df5c7b1adea877b4fe45bf67e51;p=thirdparty%2Flibvirt.git 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 --- diff --git a/src/util/virutil.c b/src/util/virutil.c index 91178d1515..2796671f4a 100644 --- a/src/util/virutil.c +++ b/src/util/virutil.c @@ -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++) { diff --git a/tests/utiltest.c b/tests/utiltest.c index 9b7a4a34f9..bd55d447b1 100644 --- a/tests/utiltest.c +++ b/tests/utiltest.c @@ -37,7 +37,8 @@ static struct testDiskName diskNamesPart[] = { }; static const char* diskNamesInvalid[] = { - "sda00", "sda01", "sdb-1" + "sda00", "sda01", "sdb-1", + "vd2" }; static int