Prevent crash when detecting fs.

This commit is contained in:
Manoel R. Abranches 2011-06-15 15:11:26 -03:00
parent 4700d08bb4
commit e23bc603f8

View file

@ -581,6 +581,16 @@ grub_net_open_real (const char *name)
return NULL; 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 static grub_err_t
grub_net_fs_open (struct grub_file *file, const char *name) 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 = static struct grub_fs grub_net_fs =
{ {
.name = "netfs", .name = "netfs",
.dir = NULL, .dir = grub_net_fs_dir,
.open = grub_net_fs_open, .open = grub_net_fs_open,
.read = grub_net_fs_read, .read = grub_net_fs_read,
.close = grub_net_fs_close, .close = grub_net_fs_close,