relocator: Fix integer underflow.
This commit is contained in:
parent
6e1ace590a
commit
eba6db6323
1 changed files with 30 additions and 20 deletions
|
@ -736,10 +736,11 @@ malloc_in_range (struct grub_relocator *rel,
|
||||||
}
|
}
|
||||||
isinsideafter = (!ncollisions && (nstarted || ((nlefto || nstartedfw)
|
isinsideafter = (!ncollisions && (nstarted || ((nlefto || nstartedfw)
|
||||||
&& !nblockfw)));
|
&& !nblockfw)));
|
||||||
|
if (from_low_priv) {
|
||||||
if (!isinsidebefore && isinsideafter)
|
if (!isinsidebefore && isinsideafter)
|
||||||
starta = from_low_priv ? ALIGN_UP (events[j].pos, align)
|
starta = ALIGN_UP (events[j].pos, align);
|
||||||
: ALIGN_DOWN (events[j].pos - size, align) + size;
|
|
||||||
if (isinsidebefore && !isinsideafter && from_low_priv)
|
if (isinsidebefore && !isinsideafter)
|
||||||
{
|
{
|
||||||
target = starta;
|
target = starta;
|
||||||
if (target < start)
|
if (target < start)
|
||||||
|
@ -748,7 +749,15 @@ malloc_in_range (struct grub_relocator *rel,
|
||||||
/* Found an usable address. */
|
/* Found an usable address. */
|
||||||
goto found;
|
goto found;
|
||||||
}
|
}
|
||||||
if (isinsidebefore && !isinsideafter && !from_low_priv)
|
} else {
|
||||||
|
if (!isinsidebefore && isinsideafter)
|
||||||
|
{
|
||||||
|
if (events[j].pos >= size)
|
||||||
|
starta = ALIGN_DOWN (events[j].pos - size, align) + size;
|
||||||
|
else
|
||||||
|
starta = 0;
|
||||||
|
}
|
||||||
|
if (isinsidebefore && !isinsideafter && starta >= size)
|
||||||
{
|
{
|
||||||
target = starta - size;
|
target = starta - size;
|
||||||
if (target > end - size)
|
if (target > end - size)
|
||||||
|
@ -758,6 +767,7 @@ malloc_in_range (struct grub_relocator *rel,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
grub_mm_base = base_saved;
|
grub_mm_base = base_saved;
|
||||||
grub_free (events);
|
grub_free (events);
|
||||||
|
|
Loading…
Reference in a new issue