From dfab719fc83f2f4cc2e66c3a6350978e662643be Mon Sep 17 00:00:00 2001 From: robertmh Date: Fri, 14 Nov 2008 20:08:47 +0000 Subject: [PATCH] 2008-11-14 Robert Millan * fs/cpio.c (grub_cpio_open): Compare `name' and `fn' by hand in order to cope with duplicate slashes. --- ChangeLog | 5 +++++ fs/cpio.c | 31 +++++++++++++++++++++++++------ 2 files changed, 30 insertions(+), 6 deletions(-) diff --git a/ChangeLog b/ChangeLog index 89955178e..834efaca0 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2008-11-14 Robert Millan + + * fs/cpio.c (grub_cpio_open): Compare `name' and `fn' by hand in + order to cope with duplicate slashes. + 2008-11-14 Robert Millan * include/grub/i386/coreboot/memory.h (GRUB_MEMORY_MACHINE_LOWER_SIZE): diff --git a/fs/cpio.c b/fs/cpio.c index 1692d6108..4965fe57d 100644 --- a/fs/cpio.c +++ b/fs/cpio.c @@ -262,6 +262,7 @@ grub_cpio_open (grub_file_t file, const char *name) struct grub_cpio_data *data; grub_uint32_t ofs; char *fn; + int i, j; #ifndef GRUB_UTIL grub_dl_ref (my_mod); @@ -283,15 +284,33 @@ grub_cpio_open (grub_file_t file, const char *name) break; } - if (grub_strcmp (name + 1, fn) == 0) + /* Compare NAME and FN by hand in order to cope with duplicate + slashes. */ + i = 1; + j = 0; + while (1) { - file->data = data; - file->size = data->size; - grub_free (fn); - - return GRUB_ERR_NONE; + if (name[i] != fn[j]) + goto no_match; + + if (name[i] == '\0') + break; + + if (name[i] == '/' && name[i+1] == '/') + i++; + + i++; + j++; } + file->data = data; + file->size = data->size; + grub_free (fn); + + return GRUB_ERR_NONE; + + no_match: + grub_free (fn); data->hofs = ofs; }