Be even more paranoid about overflow.
Requested by: ache
This commit is contained in:
parent
ae866603c7
commit
11e104c50f
@ -466,8 +466,8 @@ rman_reserve_resource_bound(struct rman *rm, u_long start, u_long end,
|
||||
}
|
||||
|
||||
amask = (1ul << RF_ALIGNMENT(flags)) - 1;
|
||||
if (start + amask < start) {
|
||||
DPRINTF(("start+amask wrapped around\n"));
|
||||
if (start > ULONG_MAX - amask) {
|
||||
DPRINTF(("start+amask would wrap around\n"));
|
||||
goto out;
|
||||
}
|
||||
|
||||
@ -487,8 +487,8 @@ rman_reserve_resource_bound(struct rman *rm, u_long start, u_long end,
|
||||
s->r_start, end));
|
||||
break;
|
||||
}
|
||||
if (s->r_start + amask < s->r_start) {
|
||||
DPRINTF(("s->r_start (%#lx) + amask (%#lx) wrapped\n",
|
||||
if (s->r_start > ULONG_MAX - amask) {
|
||||
DPRINTF(("s->r_start (%#lx) + amask (%#lx) too large\n",
|
||||
s->r_start, amask));
|
||||
break;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user