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:
authorCampbell Barton <ideasman42@gmail.com>2019-02-11 11:09:27 +0300
committerCampbell Barton <ideasman42@gmail.com>2019-02-11 11:09:27 +0300
commit1724ff29e03c9748504cbe92b3b9e4f22db01122 (patch)
treeec5fffe0af8a2f2b18d2c3ced4c849b4b966845d /source/blender/blenkernel/BKE_main.h
parent3ce5e5a85778bc339b5275198beb74d90fc65334 (diff)
readfile: skip negative sized thumbnails
We may want to use 'TEST' BCode in the future for including data besides thumbnails. This allows negative values to be used w/o attempting to load a thumbnail.
Diffstat (limited to 'source/blender/blenkernel/BKE_main.h')
-rw-r--r--source/blender/blenkernel/BKE_main.h8
1 files changed, 6 insertions, 2 deletions
diff --git a/source/blender/blenkernel/BKE_main.h b/source/blender/blenkernel/BKE_main.h
index 88387b88d96..a96c1399979 100644
--- a/source/blender/blenkernel/BKE_main.h
+++ b/source/blender/blenkernel/BKE_main.h
@@ -169,8 +169,12 @@ int set_listbasepointers(struct Main *main, struct ListBase *lb[MAX_LIBARRAY]);
#define BLEN_THUMB_SIZE 128
-#define BLEN_THUMB_MEMSIZE(_x, _y) (sizeof(BlendThumbnail) + ((size_t)(_x) * (size_t)(_y)) * sizeof(int))
-#define BLEN_THUMB_SAFE_MEMSIZE(_x, _y) ((uint64_t)_x * (uint64_t)_y < (SIZE_MAX / (sizeof(int) * 4)))
+#define BLEN_THUMB_MEMSIZE(_x, _y) \
+ (sizeof(BlendThumbnail) + ((size_t)(_x) * (size_t)(_y)) * sizeof(int))
+/** Protect against buffer overflow vulnerability & negative sizes. */
+#define BLEN_THUMB_MEMSIZE_IS_VALID(_x, _y) \
+ (((_x) > 0 && (_y) > 0) && \
+ ((uint64_t)(_x) * (uint64_t)(_y) < (SIZE_MAX / (sizeof(int) * 4))))
#ifdef __cplusplus
}