[vlc-commits] block: limit alloc size to 128MB

Rémi Denis-Courmont git at videolan.org
Tue Nov 14 10:24:04 CET 2017


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Sun Nov  5 13:44:43 2017 +0200| [a6a805f194b18f871555b9f4573a6ccf10c5491d] | committer: Thomas Guillem

block: limit alloc size to 128MB

Fuzzers don´t like large allocations. And in fact, real systems don´t
really like them either.

Modified-by: Thomas Guillem <thomas at gllm.fr>:
Changed the value from (size >> 24) to (size >> 27) (from 16 MB to 128MB).

Signed-off-by: Thomas Guillem <thomas at gllm.fr>

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=a6a805f194b18f871555b9f4573a6ccf10c5491d
---

 src/misc/block.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/src/misc/block.c b/src/misc/block.c
index 10bd5c5588..12299f36ab 100644
--- a/src/misc/block.c
+++ b/src/misc/block.c
@@ -119,6 +119,12 @@ static void BlockMetaCopy( block_t *restrict out, const block_t *in )
 
 block_t *block_Alloc (size_t size)
 {
+    if (unlikely(size >> 27))
+    {
+        errno = ENOBUFS;
+        return NULL;
+    }
+
     /* 2 * BLOCK_PADDING: pre + post padding */
     const size_t alloc = sizeof (block_t) + BLOCK_ALIGN + (2 * BLOCK_PADDING)
                        + size;



More information about the vlc-commits mailing list