Currently, read_cat_key() confuses keys of invalid types with
header-only keys. Fix that.
Signed-off-by: Ernesto A. Fernández <
ernesto.mn...@gmail.com>
---
apfsck/key.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/apfsck/key.c b/apfsck/key.c
index a15e942..4dd97b9 100644
--- a/apfsck/key.c
+++ b/apfsck/key.c
@@ -236,6 +236,9 @@ void read_cat_key(void *raw, int size, struct key *key)
key->id = cat_cnid((struct apfs_key_header *)raw);
key->type = cat_type((struct apfs_key_header *)raw);
+ if (!key->type || key->type > APFS_TYPE_MAX_VALID)
+ report("Catalog tree", "invalid key type.");
+
switch (key->type) {
case APFS_TYPE_DIR_REC:
read_dir_rec_key(raw, size, key);
--
2.11.0