df: Fix segfault when using virt-df -a filename
authorRichard W.M. Jones <rjones@redhat.com>
Tue, 30 Nov 2010 16:52:48 +0000 (16:52 +0000)
committerRichard W.M. Jones <rjones@redhat.com>
Tue, 30 Nov 2010 16:52:48 +0000 (16:52 +0000)
If 'filename' doesn't contain a '/' character then virt-df
was calculating NULL as the basename and later segfaulting.

df/main.c

index 9565464..55e5eaa 100644 (file)
--- a/df/main.c
+++ b/df/main.c
@@ -279,6 +279,8 @@ main (int argc, char *argv[])
     switch (drvs->type) {
     case drv_a:
       name = strrchr (drvs->a.filename, '/');
+      if (name == NULL)
+        name = drvs->a.filename;
       break;
     case drv_d:
       name = drvs->d.guest;