Validate size when parsing BootInfoContents::Value

Check if the content size is between 1 and 8.

Signed-off-by: Imre Kis <imre.kis@arm.com>
Change-Id: I4ef432928f7d8d96ac9e1b054c2a9ed46a6a3f1e
diff --git a/src/boot_info.rs b/src/boot_info.rs
index 74e6806..6cccd20 100644
--- a/src/boot_info.rs
+++ b/src/boot_info.rs
@@ -524,10 +524,17 @@
                     }
                 }
 
-                BootInfoContentsFormat::Value => BootInfoContents::Value {
-                    val: desc_raw.contents,
-                    len: desc_raw.size as usize,
-                },
+                BootInfoContentsFormat::Value => {
+                    let len = desc_raw.size as usize;
+                    if (1..=8).contains(&len) {
+                        BootInfoContents::Value {
+                            val: desc_raw.contents,
+                            len,
+                        }
+                    } else {
+                        return Some(Err(Error::MalformedDescriptor));
+                    }
+                }
             };
 
             return Some(Ok(BootInfo {