All of lore.kernel.org
 help / color / mirror / Atom feed
* testing a loopback device without filesystem causes a crash
@ 2009-09-13 18:58 ago
  2009-09-14  8:45 ` Colin Watson
  0 siblings, 1 reply; 3+ messages in thread
From: ago @ 2009-09-13 18:58 UTC (permalink / raw)
  To: grub-devel

Dear all,

On fezie's request I am reporting a possible bug that I experienced
when running the following:

loopback loop0 /path/to/myfile
if [ -e (loop0)/some/file ]; then
 echo ok
fi

If /path/to/myfile does not contain a filesystem, grub2 crashes (there
is a sudden restart) when I run the test.
The ls command works.

ls (loop0) => Device loop0: Unknown filesystem



^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: testing a loopback device without filesystem causes a crash
  2009-09-13 18:58 testing a loopback device without filesystem causes a crash ago
@ 2009-09-14  8:45 ` Colin Watson
  2009-09-14 15:36   ` Robert Millan
  0 siblings, 1 reply; 3+ messages in thread
From: Colin Watson @ 2009-09-14  8:45 UTC (permalink / raw)
  To: The development of GRUB 2

On Sun, Sep 13, 2009 at 07:58:56PM +0100, ago wrote:
> On fezie's request I am reporting a possible bug that I experienced
> when running the following:
> 
> loopback loop0 /path/to/myfile
> if [ -e (loop0)/some/file ]; then
>  echo ok
> fi
> 
> If /path/to/myfile does not contain a filesystem, grub2 crashes (there
> is a sudden restart) when I run the test.

The following patch fixes this. OK to commit?

2009-09-14  Colin Watson  <cjwatson@ubuntu.com>

	* commands/test.c (get_fileinfo): Return immediately if
	grub_fs_probe fails.

Index: commands/test.c
===================================================================
--- commands/test.c	(revision 2593)
+++ commands/test.c	(working copy)
@@ -88,6 +88,13 @@ test_parse (char **args, int *argn, int argc)
       }
 
     fs = grub_fs_probe (dev);
+    if (! fs)
+      {
+	grub_free (device_name);
+	grub_device_close (dev);
+	return;
+      }
+
     pathname = grub_strchr (path, ')');
     if (! pathname)
       pathname = path;

-- 
Colin Watson                                       [cjwatson@ubuntu.com]



^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: testing a loopback device without filesystem causes a crash
  2009-09-14  8:45 ` Colin Watson
@ 2009-09-14 15:36   ` Robert Millan
  0 siblings, 0 replies; 3+ messages in thread
From: Robert Millan @ 2009-09-14 15:36 UTC (permalink / raw)
  To: The development of GRUB 2

On Mon, Sep 14, 2009 at 09:45:42AM +0100, Colin Watson wrote:
> On Sun, Sep 13, 2009 at 07:58:56PM +0100, ago wrote:
> > On fezie's request I am reporting a possible bug that I experienced
> > when running the following:
> > 
> > loopback loop0 /path/to/myfile
> > if [ -e (loop0)/some/file ]; then
> >  echo ok
> > fi
> > 
> > If /path/to/myfile does not contain a filesystem, grub2 crashes (there
> > is a sudden restart) when I run the test.
> 
> The following patch fixes this. OK to commit?
> 
> 2009-09-14  Colin Watson  <cjwatson@ubuntu.com>
> 
> 	* commands/test.c (get_fileinfo): Return immediately if
> 	grub_fs_probe fails.
> 
> Index: commands/test.c
> ===================================================================
> --- commands/test.c	(revision 2593)
> +++ commands/test.c	(working copy)
> @@ -88,6 +88,13 @@ test_parse (char **args, int *argn, int argc)
>        }
>  
>      fs = grub_fs_probe (dev);
> +    if (! fs)
> +      {
> +	grub_free (device_name);
> +	grub_device_close (dev);
> +	return;
> +      }
> +

Of course!

-- 
Robert Millan

  The DRM opt-in fallacy: "Your data belongs to us. We will decide when (and
  how) you may access your data; but nobody's threatening your freedom: we
  still allow you to remove your data and not access it at all."



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2009-09-14 15:36 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-09-13 18:58 testing a loopback device without filesystem causes a crash ago
2009-09-14  8:45 ` Colin Watson
2009-09-14 15:36   ` Robert Millan

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.