+2010-01-27 Robert Millan <rmh.grub@aybabtu.com>
+
+ * util/hostfs.c: Include `<errno.h>'.
+ (grub_hostfs_read): Handle errors from fseeko() and fread().
+
2010-01-27 Robert Millan <rmh.grub@aybabtu.com>
* kern/disk.c (grub_disk_read): Fix bug that would cause infinite
/* hostfs.c - Dummy filesystem to provide access to the hosts filesystem */
/*
* GRUB -- GRand Unified Bootloader
- * Copyright (C) 2007,2008,2009 Free Software Foundation, Inc.
+ * Copyright (C) 2007,2008,2009,2010 Free Software Foundation, Inc.
*
* GRUB is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
#include <dirent.h>
#include <stdio.h>
+#include <errno.h>
/* dirent.d_type is a BSD extension, not part of POSIX */
FILE *f;
f = (FILE *) file->data;
- fseeko (f, file->offset, SEEK_SET);
- int s = fread (buf, 1, len, f);
+ if (fseeko (f, file->offset, SEEK_SET) != 0)
+ {
+ grub_error (GRUB_ERR_OUT_OF_RANGE, "fseeko: %s", strerror (errno));
+ return -1;
+ }
+
+ unsigned int s = fread (buf, 1, len, f);
+ if (s != len)
+ grub_error (GRUB_ERR_FILE_READ_ERROR, "fread: %s", strerror (errno));
- return s;
+ return (signed) s;
}
static grub_err_t