As far as virDiskNameToIndex calls virDiskNameParse and doesn't
check parameters and in most cases is used with disk->dst as a
parameter and disk->dst is by virIndexToDiskName, which can
return NULL, virDiskNameParse can crash in such cases.
Let's be paranoic and sustain even such incorrect usage.
Signed-off-by: Maxim Nestratov <mnestratov(a)virtuozzo.com>
---
src/util/virutil.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/src/util/virutil.c b/src/util/virutil.c
index d80d994..05e136d 100644
--- a/src/util/virutil.c
+++ b/src/util/virutil.c
@@ -556,6 +556,9 @@ int virDiskNameParse(const char *name, int *disk, int *partition)
static char const* const drive_prefix[] = {"fd", "hd",
"vd", "sd", "xvd", "ubd"};
size_t i;
+ if (!name)
+ return -1;
+
for (i = 0; i < ARRAY_CARDINALITY(drive_prefix); i++) {
if (STRPREFIX(name, drive_prefix[i])) {
ptr = name + strlen(drive_prefix[i]);
--
1.8.3.1