* grub-core/fs/hfsplus.c: Make parent unsigned.
(grub_hfsplus_cmp_catkey): Don't compare using subtraction, it overflows. (grub_hfsplus_cmp_extkey): Likewise
This commit is contained in:
parent
469ee10a7f
commit
4af0504b72
2 changed files with 28 additions and 12 deletions
|
@ -1,3 +1,10 @@
|
||||||
|
2011-01-03 Dave Vasilevsky <dave@vasilevsky.ca>
|
||||||
|
|
||||||
|
* grub-core/fs/hfsplus.c: Make parent unsigned.
|
||||||
|
(grub_hfsplus_cmp_catkey): Don't compare using subtraction, it
|
||||||
|
overflows.
|
||||||
|
(grub_hfsplus_cmp_extkey): Likewise
|
||||||
|
|
||||||
2011-01-03 Vladimir Serbinenko <phcoder@gmail.com>
|
2011-01-03 Vladimir Serbinenko <phcoder@gmail.com>
|
||||||
|
|
||||||
* util/grub-install.in: Correctly use bootloader_id and not
|
* util/grub-install.in: Correctly use bootloader_id and not
|
||||||
|
|
|
@ -178,7 +178,7 @@ enum grub_hfsplus_filetype
|
||||||
/* Internal representation of a catalog key. */
|
/* Internal representation of a catalog key. */
|
||||||
struct grub_hfsplus_catkey_internal
|
struct grub_hfsplus_catkey_internal
|
||||||
{
|
{
|
||||||
int parent;
|
grub_uint32_t parent;
|
||||||
char *name;
|
char *name;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -520,9 +520,12 @@ grub_hfsplus_cmp_catkey (struct grub_hfsplus_key *keya,
|
||||||
int i;
|
int i;
|
||||||
int diff;
|
int diff;
|
||||||
|
|
||||||
diff = grub_be_to_cpu32 (catkey_a->parent) - catkey_b->parent;
|
/* Safe unsigned comparison */
|
||||||
if (diff)
|
grub_uint32_t aparent = grub_be_to_cpu32 (catkey_a->parent);
|
||||||
return diff;
|
if (aparent > catkey_b->parent)
|
||||||
|
return 1;
|
||||||
|
if (aparent < catkey_b->parent)
|
||||||
|
return -1;
|
||||||
|
|
||||||
/* Change the filename in keya so the endianness is correct. */
|
/* Change the filename in keya so the endianness is correct. */
|
||||||
for (i = 0; i < grub_be_to_cpu16 (catkey_a->namelen); i++)
|
for (i = 0; i < grub_be_to_cpu16 (catkey_a->namelen); i++)
|
||||||
|
@ -555,15 +558,21 @@ grub_hfsplus_cmp_extkey (struct grub_hfsplus_key *keya,
|
||||||
{
|
{
|
||||||
struct grub_hfsplus_extkey *extkey_a = &keya->extkey;
|
struct grub_hfsplus_extkey *extkey_a = &keya->extkey;
|
||||||
struct grub_hfsplus_extkey_internal *extkey_b = &keyb->extkey;
|
struct grub_hfsplus_extkey_internal *extkey_b = &keyb->extkey;
|
||||||
int diff;
|
grub_uint32_t akey;
|
||||||
|
|
||||||
diff = grub_be_to_cpu32 (extkey_a->fileid) - extkey_b->fileid;
|
/* Safe unsigned comparison */
|
||||||
|
akey = grub_be_to_cpu32 (extkey_a->fileid);
|
||||||
|
if (akey > extkey_b->fileid)
|
||||||
|
return 1;
|
||||||
|
if (akey < extkey_b->fileid)
|
||||||
|
return -1;
|
||||||
|
|
||||||
if (diff)
|
akey = grub_be_to_cpu32 (extkey_a->start);
|
||||||
return diff;
|
if (akey > extkey_b->start)
|
||||||
|
return 1;
|
||||||
diff = grub_be_to_cpu32 (extkey_a->start) - extkey_b->start;
|
if (akey < extkey_b->start)
|
||||||
return diff;
|
return -1;
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static char *
|
static char *
|
||||||
|
|
Loading…
Add table
Reference in a new issue