Merge "FROMGIT: libfdt: fdt_offset_ptr(): Fix comparison warnings" into qt-dev am: d78db83214

Original change: https://googleplex-android-review.googlesource.com/c/platform/external/dtc/+/19527649

Change-Id: I4cb6f3b054cbd1c06e674f32d55f6cdb9f52cd5e
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
Pierre-Clément Tosi 2022-08-09 20:14:57 +00:00 committed by Automerger Merge Worker
commit a2f57e7e7e

View file

@ -76,15 +76,19 @@ int fdt_check_header(const void *fdt)
const void *fdt_offset_ptr(const void *fdt, int offset, unsigned int len) const void *fdt_offset_ptr(const void *fdt, int offset, unsigned int len)
{ {
unsigned absoffset = offset + fdt_off_dt_struct(fdt); unsigned int uoffset = offset;
unsigned int absoffset = offset + fdt_off_dt_struct(fdt);
if ((absoffset < offset) if (offset < 0)
return NULL;
if ((absoffset < uoffset)
|| ((absoffset + len) < absoffset) || ((absoffset + len) < absoffset)
|| (absoffset + len) > fdt_totalsize(fdt)) || (absoffset + len) > fdt_totalsize(fdt))
return NULL; return NULL;
if (fdt_version(fdt) >= 0x11) if (fdt_version(fdt) >= 0x11)
if (((offset + len) < offset) if (((uoffset + len) < uoffset)
|| ((offset + len) > fdt_size_dt_struct(fdt))) || ((offset + len) > fdt_size_dt_struct(fdt)))
return NULL; return NULL;