[components] [fdt] add parameter check

This commit is contained in:
Mengxi-Xu 2023-06-05 01:50:04 +08:00 committed by GitHub
parent 1c7e7738a7
commit d2308d41d7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -96,7 +96,9 @@ static int _fdt_splice(void *fdt, void *splicepoint, int oldlen, int newlen)
{
char *p = splicepoint;
char *end = (char *)fdt + _fdt_data_size(fdt);
if (oldlen <= 0)
return -FDT_ERR_BADOFFSET;
if (((p + oldlen) < p) || ((p + oldlen) > end))
return -FDT_ERR_BADOFFSET;
if ((p < (char *)fdt) || ((end - oldlen + newlen) < (char *)fdt))