From f33df2c4e69a5a38467004030cd123a32f00f028 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=A1=D0=B5=D1=80=D0=B3=D0=B5=D0=B9=20=D0=9C=D0=B0=D1=80?= =?UTF-8?q?=D0=B8=D0=BD=D0=BA=D0=B5=D0=B2=D0=B8=D1=87?= Date: Mon, 26 Dec 2022 19:38:24 +0700 Subject: [PATCH] make fdt_node_get_prop fail by end of node --- main.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/main.c b/main.c index ba83ed4..81d0f46 100644 --- a/main.c +++ b/main.c @@ -187,7 +187,10 @@ static int fdt_node_get_prop(char * filename, char * fdt, char * strings, int of buf_offset = 0; } - if (FDT_PROP == fdt32_to_cpu(*(int *)(fdt_offset_ptr_(fdt, buf, buf_offset)))) + int tag = fdt32_to_cpu(*(int *)(fdt_offset_ptr_(fdt, buf, buf_offset))); + if (FDT_END_NODE == tag) + break; + else if (FDT_PROP == tag) { const struct fdt_property *prop = fdt_offset_ptr_(fdt, buf, buf_offset); debug("prop->nameoff: %x (%x)\n", fdt32_to_cpu(prop->nameoff), fdt_off_dt_strings(fdt));