~nytpu/tlsada

3e2864a5f77becc20dadf43d090082f6f4d9c521 — nytpu 1 year, 11 months ago 3d238c7
TLS.Contexts.Read: Fix length calculation for unusual array bounds.

The previous implementation would only set Last correctly for arrays starting
at 1, this new implementation generalizes it to arrays of any range.
1 files changed, 3 insertions(+), 1 deletions(-)

M src/tls-contexts.adb
M src/tls-contexts.adb => src/tls-contexts.adb +3 -1
@@ 259,7 259,9 @@ package body TLS.Contexts is
			end case;
		end loop;

		Last := Stream_Element_Offset(size_t(Sz) / Stream_Element_Size);
		-- Subtract one from Item'First since C is zero-indexed while Item
		-- isn't necessarily.
		Last := (Item'First - 1) + Stream_Element_Offset(size_t(Sz) / Stream_Element_Size);
		if Last < Item'First then
			raise End_Error;
		end if;