aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorElvira Khabirova <e.khabirova@omp.ru>2021-11-09 18:47:19 +0300
committerDavid Gibson <david@gibson.dropbear.id.au>2021-11-17 12:22:53 +1100
commitc19a4bafa514c2c85876f0de35782abd11bed7ec (patch)
treed238ead61ff73ae28002b115f235a3e033cca6ea
parent1cc41b1c969f1fa5090b166397e4bab4ab1aa449 (diff)
downloaddtc-c19a4bafa514c2c85876f0de35782abd11bed7ec.tar.gz
libfdt: fix an incorrect integer promotion
UINT32_MAX is an integer of type unsigned int. UINT32_MAX + 1 overflows unless explicitly computed as unsigned long long. This led to some invalid addresses being treated as valid. Cast UINT32_MAX to uint64_t explicitly. Signed-off-by: Elvira Khabirova <e.khabirova@omp.ru>
-rw-r--r--libfdt/fdt_addresses.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/libfdt/fdt_addresses.c b/libfdt/fdt_addresses.c
index 9a82cd0..c40ba09 100644
--- a/libfdt/fdt_addresses.c
+++ b/libfdt/fdt_addresses.c
@@ -73,7 +73,7 @@ int fdt_appendprop_addrrange(void *fdt, int parent, int nodeoffset,
/* check validity of address */
prop = data;
if (addr_cells == 1) {
- if ((addr > UINT32_MAX) || ((UINT32_MAX + 1 - addr) < size))
+ if ((addr > UINT32_MAX) || (((uint64_t) UINT32_MAX + 1 - addr) < size))
return -FDT_ERR_BADVALUE;
fdt32_st(prop, (uint32_t)addr);