ext2: Check maximum extent length
Higher length values mean the blocks are only pre-allocated /
uninitialized.
diff --git a/src/filo-fs-ext2.adb b/src/filo-fs-ext2.adb
index 8197733..7b138b2 100644
--- a/src/filo-fs-ext2.adb
+++ b/src/filo-fs-ext2.adb
@@ -356,6 +356,7 @@
Extent_Header_Size : constant := 12;
Extent_Header_Magic : constant := 16#f30a#;
+ Initialized_Extent_Max_Len : constant := 2 ** 15;
subtype Extent_Off is Natural range 0 .. Extent_Header_Size;
subtype Extent_Idx is Natural range 1 .. (Max_Block_Index'Last + 1) / Extent_Header_Size - 1;
Dynamic_Max_Index : constant Extent_Idx := State.Static.Block_Size / Extent_Header_Size - 1;
@@ -561,7 +562,7 @@
end if;
Success :=
- Length > 0 and then
+ (0 < Length and Length <= Initialized_Extent_Max_Len) and then
Logical_Off <= FSBlock_Logical'Last - Length and then
Logical < Logical_Off + Length and then
FSBlock_Offset (Logical - Logical_Off) <= FSBlock_Offset'Last - Physical;