Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrecht Van Lommel <brechtvanlommel@gmail.com>2018-01-14 23:53:32 +0300
committerBrecht Van Lommel <brechtvanlommel@gmail.com>2018-01-17 21:59:47 +0300
commita6700362c71c3978acd53762e1f2e11e7f7a38b5 (patch)
tree1cf2d8a069c39eb0aa1384a2f80495710e89e9fd /intern/guardedalloc/MEM_guardedalloc.h
parent46204f843b5710dabb99e194aee5e3202b9688e4 (diff)
Memory: add MEM_malloc_arrayN() function to protect against overflow.
Differential Revision: https://developer.blender.org/D3002
Diffstat (limited to 'intern/guardedalloc/MEM_guardedalloc.h')
-rw-r--r--intern/guardedalloc/MEM_guardedalloc.h14
1 files changed, 14 insertions, 0 deletions
diff --git a/intern/guardedalloc/MEM_guardedalloc.h b/intern/guardedalloc/MEM_guardedalloc.h
index f6048a04cf3..a57921223e2 100644
--- a/intern/guardedalloc/MEM_guardedalloc.h
+++ b/intern/guardedalloc/MEM_guardedalloc.h
@@ -114,12 +114,26 @@ extern "C" {
extern void *(*MEM_callocN)(size_t len, const char *str) /* ATTR_MALLOC */ ATTR_WARN_UNUSED_RESULT ATTR_ALLOC_SIZE(1) ATTR_NONNULL(2);
/**
+ * Allocate a block of memory of size (len * size), with tag name
+ * str, aborting in case of integer overflows to prevent vulnerabilities.
+ * The memory is cleared. The name must be static, because only a
+ * pointer to it is stored ! */
+ extern void *(*MEM_calloc_arrayN)(size_t len, size_t size, const char *str) /* ATTR_MALLOC */ ATTR_WARN_UNUSED_RESULT ATTR_ALLOC_SIZE(1,2) ATTR_NONNULL(3);
+
+ /**
* Allocate a block of memory of size len, with tag name str. The
* name must be a static, because only a pointer to it is stored !
* */
extern void *(*MEM_mallocN)(size_t len, const char *str) /* ATTR_MALLOC */ ATTR_WARN_UNUSED_RESULT ATTR_ALLOC_SIZE(1) ATTR_NONNULL(2);
/**
+ * Allocate a block of memory of size (len * size), with tag name str,
+ * aborting in case of integer overflow to prevent vulnerabilities. The
+ * name must be a static, because only a pointer to it is stored !
+ * */
+ extern void *(*MEM_malloc_arrayN)(size_t len, size_t size, const char *str) /* ATTR_MALLOC */ ATTR_WARN_UNUSED_RESULT ATTR_ALLOC_SIZE(1,2) ATTR_NONNULL(3);
+
+ /**
* Allocate an aligned block of memory of size len, with tag name str. The
* name must be a static, because only a pointer to it is stored !
* */