Blob Blame History Raw
From 4d867ff2a454a155828a2616cd674b1a8d018260 Mon Sep 17 00:00:00 2001
From: Tomas Bzatek <tbzatek@redhat.com>
Date: Tue, 14 Jan 2014 17:20:19 +0000
Subject: Fix crash when loop-deleting non-loop device

When a non-loop device file is specified, a lookup succeeds but it's not
a UDisks2.Loop object. This change prevents a crash when null pointer is
passed further in the calls.

https://bugzilla.redhat.com/show_bug.cgi?id=1036076

Signed-off-by: David Zeuthen <zeuthen@gmail.com>
---
diff --git a/tools/udisksctl.c b/tools/udisksctl.c
index 97b0f17..209c0a3 100644
--- a/tools/udisksctl.c
+++ b/tools/udisksctl.c
@@ -1691,6 +1691,12 @@ handle_command_loop (gint        *argc,
           goto out;
         }
 
+      if (udisks_object_peek_loop (object) == NULL)
+        {
+          g_printerr ("Error: specified object is not a loop device\n");
+          goto out;
+        }
+
     delete_try_again:
       error = NULL;
       if (!udisks_loop_call_delete_sync (udisks_object_peek_loop (object),
--
cgit v0.9.0.2-2-gbebe