]> git.ipfire.org Git - thirdparty/grub.git/commitdiff
* util/deviceiter.c (compare_devices): If the by-id link for a
authorColin Watson <cjwatson@ubuntu.com>
Tue, 23 Nov 2010 17:42:06 +0000 (17:42 +0000)
committerColin Watson <cjwatson@ubuntu.com>
Tue, 23 Nov 2010 17:42:06 +0000 (17:42 +0000)
device couldn't be resolved, fall back to sorting by the by-id link
rather than segfaulting.
Reported and tested by: Daniel Mierswa.

ChangeLog
util/deviceiter.c

index 9b01330d5d16e6ccd6282eb2ed886a8207607a10..c6bbffd99b53bab5bf4c5fbdf4bf5ffebc6e05c7 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2010-11-23  Colin Watson  <cjwatson@ubuntu.com>
+
+       * util/deviceiter.c (compare_devices): If the by-id link for a
+       device couldn't be resolved, fall back to sorting by the by-id link
+       rather than segfaulting.
+       Reported and tested by: Daniel Mierswa.
+
 2010-11-23  Colin Watson  <cjwatson@ubuntu.com>
 
        * Makefile.util.def (grub-menulst2cfg): List libraries in ldadd, not
index 34d34b7bbafa245a5b82f11e0cf36ccddfc258b2..1de8e54df3391373a78fe30d272c7d827fdc5d2d 100644 (file)
@@ -485,12 +485,15 @@ compare_devices (const void *a, const void *b)
 {
   const struct device *left = (const struct device *) a;
   const struct device *right = (const struct device *) b;
-  int ret;
-  ret = strcmp (left->kernel, right->kernel);
-  if (ret)
-    return ret;
-  else
-    return strcmp (left->stable, right->stable);
+
+  if (left->kernel && right->kernel)
+    {
+      int ret = strcmp (left->kernel, right->kernel);
+      if (ret)
+       return ret;
+    }
+
+  return strcmp (left->stable, right->stable);
 }
 #endif /* __linux__ */