diff options
author | Richard W.M. Jones <rjones@redhat.com> | 2012-09-28 15:00:26 +0100 |
---|---|---|
committer | Richard W.M. Jones <rjones@redhat.com> | 2012-09-28 15:09:51 +0100 |
commit | 6f53d49a27fbf7f1b5c22080e2509375e128d5e4 (patch) | |
tree | a687df19e5cebfefc3f8ed8e210ebde3473e977a | |
parent | 9ea6e9701461e594033999150f930cc4fafec4d2 (diff) | |
download | libguestfs-6f53d49a27fbf7f1b5c22080e2509375e128d5e4.tar.gz libguestfs-6f53d49a27fbf7f1b5c22080e2509375e128d5e4.tar.xz libguestfs-6f53d49a27fbf7f1b5c22080e2509375e128d5e4.zip |
daemon: When sorting devices, don't fail on mix of /dev/sd and /dev/vd
(RHBZ#858128).
If compare_device_names was given two devices with devices with
different interfaces (eg. /dev/sda and /dev/vda) then it would try to
compare the partition numbers, and fail when it could parse them.
It's arguable what we should be doing in this case (except for
strongly discouraging people from using the interface feature), but
let's at least not cause the daemon to assert-fail.
Found by Red Hat QA, thanks Mohua Li.
-rw-r--r-- | daemon/guestfsd.c | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/daemon/guestfsd.c b/daemon/guestfsd.c index 0db56e49..487662f2 100644 --- a/daemon/guestfsd.c +++ b/daemon/guestfsd.c @@ -558,6 +558,14 @@ compare_device_names (const char *a, const char *b) a += a_devlen; b += a_devlen; + /* If no partition numbers, bail -- the devices are the same. This + * can happen in one peculiar case: where you have a mix of devices + * with different interfaces (eg. /dev/sda and /dev/vda). + * (RHBZ#858128). + */ + if (!*a && !*b) + return 0; + r = sscanf (a, "%d", &a_partnum); assert (r == 1); r = sscanf (b, "%d", &b_partnum); |