Fix integer wrap sanitisation.
Test: make check
Bug: 239630493
Bug: 242096164
Change-Id: I232155e7f7a54271a6a3e3a7cd91ed6bbabc051f
Merged-In: I232155e7f7a54271a6a3e3a7cd91ed6bbabc051f
(cherry picked from commit 05dec6d182
)
This commit is contained in:
parent
d78db83214
commit
61e10c9c53
1 changed files with 10 additions and 4 deletions
14
libfdt/fdt.c
14
libfdt/fdt.c
|
@ -124,9 +124,15 @@ uint32_t fdt_next_tag(const void *fdt, int startoffset, int *nextoffset)
|
|||
lenp = fdt_offset_ptr(fdt, offset, sizeof(*lenp));
|
||||
if (!lenp)
|
||||
return FDT_END; /* premature end */
|
||||
/* skip-name offset, length and value */
|
||||
offset += sizeof(struct fdt_property) - FDT_TAGSIZE
|
||||
+ fdt32_to_cpu(*lenp);
|
||||
|
||||
/* skip-name offset, length */
|
||||
offset += sizeof(struct fdt_property) - FDT_TAGSIZE;
|
||||
|
||||
if (!fdt_offset_ptr(fdt, offset, fdt32_to_cpu(*lenp)))
|
||||
return FDT_END; /* premature end */
|
||||
|
||||
/* skip value */
|
||||
offset += fdt32_to_cpu(*lenp);
|
||||
break;
|
||||
|
||||
case FDT_END:
|
||||
|
@ -138,7 +144,7 @@ uint32_t fdt_next_tag(const void *fdt, int startoffset, int *nextoffset)
|
|||
return FDT_END;
|
||||
}
|
||||
|
||||
if (!fdt_offset_ptr(fdt, startoffset, offset - startoffset))
|
||||
if (offset <= startoffset || !fdt_offset_ptr(fdt, startoffset, offset - startoffset))
|
||||
return FDT_END; /* premature end */
|
||||
|
||||
*nextoffset = FDT_TAGALIGN(offset);
|
||||
|
|
Loading…
Reference in a new issue