mirror of
https://github.com/Atmosphere-NX/Atmosphere
synced 2024-11-10 07:06:34 +00:00
Fix inverted condition issue in check_32bit_address_range_loadable
This commit is contained in:
parent
1fd098e074
commit
880f49cfa5
3 changed files with 3 additions and 3 deletions
|
@ -90,7 +90,7 @@ void load_stage2(const char *bct0) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!check_32bit_address_range_loadable(config.load_address, size)) {
|
if (!check_32bit_address_range_loadable(config.load_address, size)) {
|
||||||
printk("Error: Stage2 has an invalid load address & size combination!\n");
|
printk("Error: Stage2 has an invalid load address & size combination (0x%08x 0x%08x)!\n", config.load_address, size);
|
||||||
generic_panic();
|
generic_panic();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -78,7 +78,7 @@ static inline bool check_32bit_address_loadable(uintptr_t addr) {
|
||||||
|
|
||||||
static inline bool check_32bit_address_range_loadable(uintptr_t addr, size_t size) {
|
static inline bool check_32bit_address_range_loadable(uintptr_t addr, size_t size) {
|
||||||
return
|
return
|
||||||
__builtin_add_overflow_p(addr, size, (uintptr_t)0) && /* the range doesn't overflow */
|
!__builtin_add_overflow_p(addr, size, (uintptr_t)0) && /* the range doesn't overflow */
|
||||||
check_32bit_address_loadable(addr) && check_32bit_address_loadable(addr + size) && /* bounds are valid */
|
check_32bit_address_loadable(addr) && check_32bit_address_loadable(addr + size) && /* bounds are valid */
|
||||||
!(addr >= 0x40010000u && addr + size >= 0x40040000u) /* the range doesn't cross MMIO */
|
!(addr >= 0x40010000u && addr + size >= 0x40040000u) /* the range doesn't cross MMIO */
|
||||||
;
|
;
|
||||||
|
|
|
@ -78,7 +78,7 @@ static inline bool check_32bit_address_loadable(uintptr_t addr) {
|
||||||
|
|
||||||
static inline bool check_32bit_address_range_loadable(uintptr_t addr, size_t size) {
|
static inline bool check_32bit_address_range_loadable(uintptr_t addr, size_t size) {
|
||||||
return
|
return
|
||||||
__builtin_add_overflow_p(addr, size, (uintptr_t)0) && /* the range doesn't overflow */
|
!__builtin_add_overflow_p(addr, size, (uintptr_t)0) && /* the range doesn't overflow */
|
||||||
check_32bit_address_loadable(addr) && check_32bit_address_loadable(addr + size) && /* bounds are valid */
|
check_32bit_address_loadable(addr) && check_32bit_address_loadable(addr + size) && /* bounds are valid */
|
||||||
!(addr >= 0x40010000u && addr + size >= 0x40040000u) /* the range doesn't cross MMIO */
|
!(addr >= 0x40010000u && addr + size >= 0x40040000u) /* the range doesn't cross MMIO */
|
||||||
;
|
;
|
||||||
|
|
Loading…
Reference in a new issue