]> git.ipfire.org Git - thirdparty/grub.git/commitdiff
Prevent crash when detecting fs.
authorManoel R. Abranches <mrabran@br.ibm.com>
Wed, 15 Jun 2011 18:11:26 +0000 (15:11 -0300)
committerManoel R. Abranches <mrabran@br.ibm.com>
Wed, 15 Jun 2011 18:11:26 +0000 (15:11 -0300)
grub-core/net/net.c

index 1232b3c7417350aa8f09ab67d7781f2ad7638aa1..380eec3b54373da0310b5df612247300d7b3db70 100644 (file)
@@ -581,6 +581,16 @@ grub_net_open_real (const char *name)
   return NULL;
 }
 
+static grub_err_t
+grub_net_fs_dir (grub_device_t device, const char *path __attribute__ ((unused)),
+              int (*hook) (const char *filename,
+                           const struct grub_dirhook_info *info) __attribute__ ((unused)))
+{
+  if (!device->net)
+    return grub_error (GRUB_ERR_BAD_FS, "invalid extent");
+  return GRUB_ERR_NONE;
+}
+
 static grub_err_t
 grub_net_fs_open (struct grub_file *file, const char *name)
 {
@@ -1014,7 +1024,7 @@ grub_cmd_dhcpopt (struct grub_command *cmd __attribute__ ((unused)),
 static struct grub_fs grub_net_fs =
   {
     .name = "netfs",
-    .dir = NULL,
+    .dir = grub_net_fs_dir,
     .open = grub_net_fs_open,
     .read = grub_net_fs_read,
     .close = grub_net_fs_close,