* grub-core/fs/cpio.c (grub_cpio_dir): Handle subdirs correctly.

This commit is contained in:
Vladimir 'phcoder' Serbinenko 2011-11-25 14:12:05 +01:00
parent 10b64f1cf4
commit adac52113d
2 changed files with 11 additions and 5 deletions

View file

@ -1,3 +1,7 @@
2011-11-25 Vladimir Serbinenko <phcoder@gmail.com>
* grub-core/fs/cpio.c (grub_cpio_dir): Handle subdirs correctly.
2011-11-16 Vladimir Serbinenko <phcoder@gmail.com> 2011-11-16 Vladimir Serbinenko <phcoder@gmail.com>
* grub-core/kern/dl.c (grub_dl_load_segments): Fix alignment handling. * grub-core/kern/dl.c (grub_dl_load_segments): Fix alignment handling.

View file

@ -404,13 +404,15 @@ grub_cpio_dir (grub_device_t device, const char *path_in,
{ {
struct grub_cpio_data *data; struct grub_cpio_data *data;
grub_disk_addr_t ofs; grub_disk_addr_t ofs;
char *prev, *name, *path; char *prev, *name, *path, *ptr;
grub_size_t len; grub_size_t len;
int symlinknest = 0; int symlinknest = 0;
path = grub_strdup (path_in + 1); path = grub_strdup (path_in + 1);
if (!path) if (!path)
return grub_errno; return grub_errno;
for (ptr = path + grub_strlen (path) - 1; ptr >= path && *ptr == '/'; ptr--)
*ptr = 0;
grub_dl_ref (my_mod); grub_dl_ref (my_mod);
@ -443,14 +445,14 @@ grub_cpio_dir (grub_device_t device, const char *path_in,
char *p, *n; char *p, *n;
n = name + len; n = name + len;
if (*n == '/') while (*n == '/')
n++; n++;
p = grub_strchr (name + len, '/'); p = grub_strchr (n, '/');
if (p) if (p)
*p = 0; *p = 0;
if (((!prev) || (grub_strcmp (prev, name) != 0)) && name[len] != 0) if (((!prev) || (grub_strcmp (prev, n) != 0)) && *n != 0)
{ {
struct grub_dirhook_info info; struct grub_dirhook_info info;
grub_memset (&info, 0, sizeof (info)); grub_memset (&info, 0, sizeof (info));
@ -458,7 +460,7 @@ grub_cpio_dir (grub_device_t device, const char *path_in,
info.mtime = mtime; info.mtime = mtime;
info.mtimeset = 1; info.mtimeset = 1;
hook (name + len, &info); hook (n, &info);
grub_free (prev); grub_free (prev);
prev = name; prev = name;
} }