Skip to content

Commit e04d022

Browse files
committed
Add stern warning for fromListN
1 parent 9281d67 commit e04d022

File tree

4 files changed

+20
-4
lines changed

4 files changed

+20
-4
lines changed

vector/src/Data/Vector/Generic.hs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2297,7 +2297,11 @@ fromList :: Vector v a => [a] -> v a
22972297
{-# INLINE fromList #-}
22982298
fromList = unstream . Bundle.fromList
22992299

2300-
-- | /O(n)/ Convert the first @n@ elements of a list to a vector.
2300+
-- | /O(n)/ Convert the first @n@ elements of a list to a vector. It's
2301+
-- expected that supplied list will be exactly @n@ elements long. As
2302+
-- optimization this function allocates buffer for @n@ elements and
2303+
-- could be used to DoS by exhausting memory if attacker controls that
2304+
-- parameter.
23012305
--
23022306
-- @
23032307
-- fromListN n xs = 'fromList' ('take' n xs)

vector/src/Data/Vector/Primitive.hs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1786,7 +1786,11 @@ fromList :: Prim a => [a] -> Vector a
17861786
{-# INLINE fromList #-}
17871787
fromList = G.fromList
17881788

1789-
-- | /O(n)/ Convert the first @n@ elements of a list to a vector.
1789+
-- | /O(n)/ Convert the first @n@ elements of a list to a vector. It's
1790+
-- expected that supplied list will be exactly @n@ elements long. As
1791+
-- optimization this function allocates buffer for @n@ elements and
1792+
-- could be used to DoS by exhausting memory if attacker controls that
1793+
-- parameter.
17901794
--
17911795
-- @
17921796
-- fromListN n xs = 'fromList' ('take' n xs)

vector/src/Data/Vector/Storable.hs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1832,7 +1832,11 @@ fromList :: Storable a => [a] -> Vector a
18321832
{-# INLINE fromList #-}
18331833
fromList = G.fromList
18341834

1835-
-- | /O(n)/ Convert the first @n@ elements of a list to a vector.
1835+
-- | /O(n)/ Convert the first @n@ elements of a list to a vector. It's
1836+
-- expected that supplied list will be exactly @n@ elements long. As
1837+
-- optimization this function allocates buffer for @n@ elements and
1838+
-- could be used to DoS by exhausting memory if attacker controls that
1839+
-- parameter.
18361840
--
18371841
-- @
18381842
-- fromListN n xs = 'fromList' ('take' n xs)

vector/src/Data/Vector/Unboxed.hs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1878,7 +1878,11 @@ fromList :: Unbox a => [a] -> Vector a
18781878
{-# INLINE fromList #-}
18791879
fromList = G.fromList
18801880

1881-
-- | /O(n)/ Convert the first @n@ elements of a list to a vector.
1881+
-- | /O(n)/ Convert the first @n@ elements of a list to a vector. It's
1882+
-- expected that supplied list will be exactly @n@ elements long. As
1883+
-- optimization this function allocates buffer for @n@ elements and
1884+
-- could be used to DoS by exhausting memory if attacker controls that
1885+
-- parameter.
18821886
--
18831887
-- @
18841888
-- fromListN n xs = 'fromList' ('take' n xs)

0 commit comments

Comments
 (0)