aboutsummaryrefslogtreecommitdiff
path: root/hdata/hdif.c
diff options
context:
space:
mode:
Diffstat (limited to 'hdata/hdif.c')
-rw-r--r--hdata/hdif.c12
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);