MarshalAs(UnManaged.ByValArray) overflow.
For non-blittable embedded array in structs we ignored the SizeConst and wrote past the
buffer when number of elementsin the arrayis greater than SizeConst.Fix is to truncate
the array at SizeConst
MarshalAs(UnManaged.ByValTStr)
Very subtle case when the SizeConst == Number of bytes required to marshal , we
write the null one past the buffer.This happens only on machine with non-english
(multi-byte) locale as default. Fix is to check the number of bytes required and
truncate the correctly leaving space for the terminating null.
Commit migrated from https://github.com/dotnet/coreclr/commit/
8d51b631b3f582a093a108acfa28c2390fe85f41