on master help sign in
Add a note about buffer overflow check in deserializeAt
commit8ff75f25df0768247f374eb539a79eb15b2fba3a authorHarendra Kumar <harendra@composewell.com> dateSun 26 Nov 2023, 02:42 (3 years ago) parented07663
1 file changed+7−3
core/src/Streamly/Internal/Data/Serialize/Type.hs+7−3
core/src/Streamly/Internal/Data/Serialize/Type.hs+7−3
@@ -127,9 +127,13 @@ class Serialize a where
127127 -- offset but that may require traversing the Haskell structure again to get
128128 -- the size. Therefore, this is a performance optimization.
129129
130− -- | @deserializeAt byte-offset array arrayLen@ deserializes a value from the
131− -- given byte-offset in the array. Returns a tuple consisting of the next
132− -- byte-offset and the deserialized value.
130+ -- | @deserializeAt byte-offset array arrayLen@ deserializes a value from
131+ -- the given byte-offset in the array. Returns a tuple consisting of the
132+ -- next byte-offset and the deserialized value.
133+ --
134+ -- The arrayLen passed is the entire length of the input buffer. It is to
135+ -- be used to check if we would overflow the input buffer when
136+ -- deserializing.
133137 --
134138 -- Throws an exception if the operation would exceed the supplied arrayLen.
135139 deserializeAt :: Int -> MutByteArray -> Int -> IO (Int, a)