diff options
author | Nicholas Piggin <npiggin@gmail.com> | 2023-09-06 20:10:13 +1000 |
---|---|---|
committer | Reza Arbab <arbab@linux.ibm.com> | 2023-10-11 15:07:23 -0500 |
commit | d368523114179996a777fe323bb0178c8d1e2388 (patch) | |
tree | 7902960fff89259bc5784ae05bc00fea12bd718c | |
parent | f79dea508d90f8fdaded75a52106c79b3d392871 (diff) | |
download | skiboot-d368523114179996a777fe323bb0178c8d1e2388.zip skiboot-d368523114179996a777fe323bb0178c8d1e2388.tar.gz skiboot-d368523114179996a777fe323bb0178c8d1e2388.tar.bz2 |
hdata: Make hdata child accessors check the header
Like other (idata) accessors already do, check the common header in
hdata child accessor calls.
Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
Signed-off-by: Reza Arbab <arbab@linux.ibm.com>
-rw-r--r-- | hdata/hdif.c | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/hdata/hdif.c b/hdata/hdif.c index 13c128c..aba7f36 100644 --- a/hdata/hdif.c +++ b/hdata/hdif.c @@ -157,6 +157,12 @@ HDIF_child_arr(const struct HDIF_common_hdr *hdif, unsigned int idx) { struct HDIF_child_ptr *children; + if (!HDIF_check(hdif, NULL)) { + prerror("HDIF: Bad header format !\n"); + backtrace(); + return NULL; + } + children = (void *)hdif + be32_to_cpu(hdif->child_off); if (idx >= be16_to_cpu(hdif->child_count)) { @@ -177,6 +183,12 @@ struct HDIF_common_hdr *HDIF_child(const struct HDIF_common_hdr *hdif, struct HDIF_common_hdr *ret; long child_off; + if (!HDIF_check(hdif, NULL)) { + prerror("HDIF: Bad header format !\n"); + backtrace(); + return NULL; + } + /* child must be in hdif's child array */ child_off = (void *)child - (base + be32_to_cpu(hdif->child_off)); assert(child_off % sizeof(struct HDIF_child_ptr) == 0); |