Browse Source

libfdt: Handle failed get_name() on BEGIN_NODE

Validate the return value of fdt_get_name() as an ill-formed DT, causing
it to fail, could result in fdt_check_full() dereferencing NULL.

fixes: a2def54799 ("libfdt: Check that the root-node name is empty")
Signed-off-by: Pierre-Clément Tosi <ptosi@google.com>
Message-Id: <20220714083848.958492-1-ptosi@google.com>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
main
Pierre-Clément Tosi 2 years ago committed by David Gibson
parent
commit
fda71da26e
  1. 2
      libfdt/fdt_check.c

2
libfdt/fdt_check.c

@ -66,7 +66,7 @@ int fdt_check_full(const void *fdt, size_t bufsize) @@ -66,7 +66,7 @@ int fdt_check_full(const void *fdt, size_t bufsize)
int len;

name = fdt_get_name(fdt, offset, &len);
if (*name || len)
if (!name || *name || len)
return -FDT_ERR_BADSTRUCTURE;
}
break;

Loading…
Cancel
Save