2009-07-06 Pavel Roskin <proski@gnu.org>

* commands/search.c (search_fs): Fix potential NULL pointer
	dereference.
This commit is contained in:
proski 2009-07-07 03:05:01 +00:00
parent 4a11b60f10
commit 99f6804167
2 changed files with 9 additions and 4 deletions

View File

@ -1,5 +1,8 @@
2009-07-06 Pavel Roskin <proski@gnu.org>
* commands/search.c (search_fs): Fix potential NULL pointer
dereference.
* commands/search.c (search_fs): Replace QUID macro with quid_fn
function pointer.

View File

@ -68,17 +68,19 @@ search_fs (const char *key, const char *var, int no_floppy, int is_uuid)
{
grub_fs_t fs;
int (*compare_fn) (const char *, const char *);
grub_err_t (*quid_fn) (grub_device_t, char **);
fs = grub_fs_probe (dev);
compare_fn = is_uuid ? grub_strcasecmp : grub_strcmp;
quid_fn = is_uuid ? fs->uuid : fs->label;
if (fs && quid_fn)
if (fs && (is_uuid ? fs->uuid : fs->label))
{
char *quid;
quid_fn (dev, &quid);
if (is_uuid)
fs->uuid (dev, &quid);
else
fs->label (dev, &quid);
if (grub_errno == GRUB_ERR_NONE && quid)
{
if (compare_fn (quid, key) == 0)