mirror of
https://git.codelinaro.org/clo/qsdk/oss/boot/u-boot-2016.git
synced 2025-12-10 07:44:53 +01:00
lib: fdt: use ULONG_MAX for boundary checks
We are typecasting the fdt_start and other parameters to unit64_t. So ULONG_MAX should be used for the boundary check. Signed-off-by: Rajkumar Ayyasamy <arajkuma@codeaurora.org> Change-Id: I42b4c0cb05902410c4e18553017c016bdd312207
This commit is contained in:
parent
3a663227a3
commit
a48d6c2615
1 changed files with 3 additions and 3 deletions
|
|
@ -14,7 +14,7 @@
|
||||||
|
|
||||||
#include "libfdt_internal.h"
|
#include "libfdt_internal.h"
|
||||||
|
|
||||||
#define UINT_MAX (~0U)
|
#define ULONG_MAX (~0UL)
|
||||||
|
|
||||||
int fdt_check_header(const void *fdt)
|
int fdt_check_header(const void *fdt)
|
||||||
{
|
{
|
||||||
|
|
@ -41,13 +41,13 @@ int fdt_check_header(const void *fdt)
|
||||||
}
|
}
|
||||||
fdt_end = fdt_start + fdt_totalsize(fdt);
|
fdt_end = fdt_start + fdt_totalsize(fdt);
|
||||||
|
|
||||||
if (((uint64_t)fdt_start + (uint64_t)fdt_off_dt_struct(fdt) + (uint64_t)fdt_size_dt_struct(fdt)) > UINT_MAX)
|
if (((uint64_t)fdt_start + (uint64_t)fdt_off_dt_struct(fdt) + (uint64_t)fdt_size_dt_struct(fdt)) > ULONG_MAX)
|
||||||
return FDT_ERR_BADOFFSET;
|
return FDT_ERR_BADOFFSET;
|
||||||
|
|
||||||
if ((fdt_start + fdt_off_dt_struct(fdt) + fdt_size_dt_struct(fdt)) > fdt_end)
|
if ((fdt_start + fdt_off_dt_struct(fdt) + fdt_size_dt_struct(fdt)) > fdt_end)
|
||||||
return FDT_ERR_BADOFFSET;
|
return FDT_ERR_BADOFFSET;
|
||||||
|
|
||||||
if (((uint64_t)fdt_start + (uint64_t)fdt_off_dt_strings(fdt) + (uint64_t)fdt_size_dt_strings(fdt)) > UINT_MAX)
|
if (((uint64_t)fdt_start + (uint64_t)fdt_off_dt_strings(fdt) + (uint64_t)fdt_size_dt_strings(fdt)) > ULONG_MAX)
|
||||||
return FDT_ERR_BADOFFSET;
|
return FDT_ERR_BADOFFSET;
|
||||||
|
|
||||||
if ((fdt_start + fdt_off_dt_strings(fdt) + fdt_size_dt_strings(fdt)) > fdt_end)
|
if ((fdt_start + fdt_off_dt_strings(fdt) + fdt_size_dt_strings(fdt)) > fdt_end)
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue