* grub-core/fs/hfsplus.c (grub_hfsplus_btree_iterate_node): Add btree
loop check using Brent algorithm. (grub_hfsplus_btree_search): Likewise.
This commit is contained in:
parent
6753c0ec3a
commit
ed167a8027
2 changed files with 31 additions and 1 deletions
|
@ -1,3 +1,9 @@
|
||||||
|
2012-02-24 Vladimir Serbinenko <phcoder@gmail.com>
|
||||||
|
|
||||||
|
* grub-core/fs/hfsplus.c (grub_hfsplus_btree_iterate_node): Add btree
|
||||||
|
loop check using Brent algorithm.
|
||||||
|
(grub_hfsplus_btree_search): Likewise.
|
||||||
|
|
||||||
2012-02-24 Vladimir Serbinenko <phcoder@gmail.com>
|
2012-02-24 Vladimir Serbinenko <phcoder@gmail.com>
|
||||||
|
|
||||||
* util/grub-install.in: Fix usage of wrong device for PreP install.
|
* util/grub-install.in: Fix usage of wrong device for PreP install.
|
||||||
|
|
|
@ -612,6 +612,8 @@ grub_hfsplus_btree_iterate_node (struct grub_hfsplus_btree *btree,
|
||||||
int (*hook) (void *record))
|
int (*hook) (void *record))
|
||||||
{
|
{
|
||||||
grub_disk_addr_t rec;
|
grub_disk_addr_t rec;
|
||||||
|
grub_uint64_t saved_node = -1;
|
||||||
|
grub_uint64_t node_count = 0;
|
||||||
|
|
||||||
for (;;)
|
for (;;)
|
||||||
{
|
{
|
||||||
|
@ -627,8 +629,18 @@ grub_hfsplus_btree_iterate_node (struct grub_hfsplus_btree *btree,
|
||||||
if (! first_node->next)
|
if (! first_node->next)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
if (node_count && first_node->next == saved_node)
|
||||||
|
{
|
||||||
|
grub_error (GRUB_ERR_BAD_FS, "HFS+ btree loop");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
if (!(node_count & (node_count - 1)))
|
||||||
|
saved_node = first_node->next;
|
||||||
|
node_count++;
|
||||||
|
|
||||||
if (grub_hfsplus_read_file (&btree->file, 0,
|
if (grub_hfsplus_read_file (&btree->file, 0,
|
||||||
(grub_be_to_cpu32 (first_node->next)
|
(((grub_disk_addr_t)
|
||||||
|
grub_be_to_cpu32 (first_node->next))
|
||||||
* btree->nodesize),
|
* btree->nodesize),
|
||||||
btree->nodesize, cnode) <= 0)
|
btree->nodesize, cnode) <= 0)
|
||||||
return 1;
|
return 1;
|
||||||
|
@ -656,16 +668,28 @@ grub_hfsplus_btree_search (struct grub_hfsplus_btree *btree,
|
||||||
char *node;
|
char *node;
|
||||||
struct grub_hfsplus_btnode *nodedesc;
|
struct grub_hfsplus_btnode *nodedesc;
|
||||||
grub_disk_addr_t rec;
|
grub_disk_addr_t rec;
|
||||||
|
grub_uint64_t save_node;
|
||||||
|
grub_uint64_t node_count = 0;
|
||||||
|
|
||||||
node = grub_malloc (btree->nodesize);
|
node = grub_malloc (btree->nodesize);
|
||||||
if (! node)
|
if (! node)
|
||||||
return grub_errno;
|
return grub_errno;
|
||||||
|
|
||||||
currnode = btree->root;
|
currnode = btree->root;
|
||||||
|
save_node = currnode - 1;
|
||||||
while (1)
|
while (1)
|
||||||
{
|
{
|
||||||
int match = 0;
|
int match = 0;
|
||||||
|
|
||||||
|
if (save_node == currnode)
|
||||||
|
{
|
||||||
|
grub_free (node);
|
||||||
|
return grub_error (GRUB_ERR_BAD_FS, "HFS+ btree loop");
|
||||||
|
}
|
||||||
|
if (!(node_count & (node_count - 1)))
|
||||||
|
save_node = currnode;
|
||||||
|
node_count++;
|
||||||
|
|
||||||
/* Read a node. */
|
/* Read a node. */
|
||||||
if (grub_hfsplus_read_file (&btree->file, 0,
|
if (grub_hfsplus_read_file (&btree->file, 0,
|
||||||
(grub_disk_addr_t) currnode
|
(grub_disk_addr_t) currnode
|
||||||
|
|
Loading…
Reference in a new issue