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-15 00:14:20 +0300
committerBrecht Van Lommel <brechtvanlommel@gmail.com>2018-01-18 02:54:07 +0300
commite04d7c49dca9dc7bbf1cbe446b612aaa5ba12581 (patch)
treef9248150341b73cd72978f9075a453fe021c2995 /source/blender/blenloader/intern
parente0f2c7aff484c7448903a1466829675494ebae6c (diff)
Fix buffer overflow vulnerabilities in mesh code.
Solves these security issues from T52924: CVE-2017-12081 CVE-2017-12082 CVE-2017-12086 CVE-2017-12099 CVE-2017-12100 CVE-2017-12101 CVE-2017-12105 While the specific overflow issue may be fixed, loading the repro .blend files may still crash because they are incomplete and corrupt. The way they crash may be impossible to exploit, but this is difficult to prove. Differential Revision: https://developer.blender.org/D3002
Diffstat (limited to 'source/blender/blenloader/intern')
-rw-r--r--source/blender/blenloader/intern/readfile.c18
-rw-r--r--source/blender/blenloader/intern/versioning_250.c2
-rw-r--r--source/blender/blenloader/intern/versioning_legacy.c2
3 files changed, 11 insertions, 11 deletions
diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c
index 51b77938dea..8edaf071f36 100644
--- a/source/blender/blenloader/intern/readfile.c
+++ b/source/blender/blenloader/intern/readfile.c
@@ -289,7 +289,7 @@ static OldNewMap *oldnewmap_new(void)
OldNewMap *onm= MEM_callocN(sizeof(*onm), "OldNewMap");
onm->entriessize = 1024;
- onm->entries = MEM_mallocN(sizeof(*onm->entries)*onm->entriessize, "OldNewMap.entries");
+ onm->entries = MEM_malloc_arrayN(onm->entriessize, sizeof(*onm->entries), "OldNewMap.entries");
return onm;
}
@@ -536,7 +536,7 @@ void blo_split_main(ListBase *mainlist, Main *main)
/* (Library.temp_index -> Main), lookup table */
const unsigned int lib_main_array_len = BLI_listbase_count(&main->library);
- Main **lib_main_array = MEM_mallocN(lib_main_array_len * sizeof(*lib_main_array), __func__);
+ Main **lib_main_array = MEM_malloc_arrayN(lib_main_array_len, sizeof(*lib_main_array), __func__);
int i = 0;
for (Library *lib = main->library.first; lib; lib = lib->id.next, i++) {
@@ -1994,7 +1994,7 @@ static void test_pointer_array(FileData *fd, void **mat)
len = MEM_allocN_len(*mat)/fd->filesdna->pointerlen;
if (fd->filesdna->pointerlen==8 && fd->memsdna->pointerlen==4) {
- ipoin=imat= MEM_mallocN(len * 4, "newmatar");
+ ipoin=imat= MEM_malloc_arrayN(len, 4, "newmatar");
lpoin= *mat;
while (len-- > 0) {
@@ -2009,7 +2009,7 @@ static void test_pointer_array(FileData *fd, void **mat)
}
if (fd->filesdna->pointerlen==4 && fd->memsdna->pointerlen==8) {
- lpoin = lmat = MEM_mallocN(len * 8, "newmatar");
+ lpoin = lmat = MEM_malloc_arrayN(len, 8, "newmatar");
ipoin = *mat;
while (len-- > 0) {
@@ -3871,7 +3871,7 @@ static void direct_link_curve(FileData *fd, Curve *cu)
else {
cu->nurb.first=cu->nurb.last= NULL;
- tb = MEM_callocN(MAXTEXTBOX*sizeof(TextBox), "TextBoxread");
+ tb = MEM_calloc_arrayN(MAXTEXTBOX, sizeof(TextBox), "TextBoxread");
if (cu->tb) {
memcpy(tb, cu->tb, cu->totbox*sizeof(TextBox));
MEM_freeN(cu->tb);
@@ -5266,9 +5266,9 @@ static void direct_link_modifiers(FileData *fd, ListBase *lb)
collmd->xnew = newdataadr(fd, collmd->xnew);
collmd->mfaces = newdataadr(fd, collmd->mfaces);
- collmd->current_x = MEM_callocN(sizeof(MVert)*collmd->numverts, "current_x");
- collmd->current_xnew = MEM_callocN(sizeof(MVert)*collmd->numverts, "current_xnew");
- collmd->current_v = MEM_callocN(sizeof(MVert)*collmd->numverts, "current_v");
+ collmd->current_x = MEM_calloc_arrayN(collmd->numverts, sizeof(MVert), "current_x");
+ collmd->current_xnew = MEM_calloc_arrayN(collmd->numverts, sizeof(MVert), "current_xnew");
+ collmd->current_v = MEM_calloc_arrayN(collmd->numverts, sizeof(MVert), "current_v");
#endif
collmd->x = NULL;
@@ -8763,7 +8763,7 @@ static void sort_bhead_old_map(FileData *fd)
fd->tot_bheadmap = tot;
if (tot == 0) return;
- bhs = fd->bheadmap = MEM_mallocN(tot * sizeof(struct BHeadSort), "BHeadSort");
+ bhs = fd->bheadmap = MEM_malloc_arrayN(tot, sizeof(struct BHeadSort), "BHeadSort");
for (bhead = blo_firstbhead(fd); bhead; bhead = blo_nextbhead(fd, bhead), bhs++) {
bhs->bhead = bhead;
diff --git a/source/blender/blenloader/intern/versioning_250.c b/source/blender/blenloader/intern/versioning_250.c
index 1956a17d57b..97fdee748d5 100644
--- a/source/blender/blenloader/intern/versioning_250.c
+++ b/source/blender/blenloader/intern/versioning_250.c
@@ -951,7 +951,7 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *main)
if (ob->totcol && ob->matbits == NULL) {
int a;
- ob->matbits = MEM_callocN(sizeof(char)*ob->totcol, "ob->matbits");
+ ob->matbits = MEM_calloc_arrayN(ob->totcol, sizeof(char), "ob->matbits");
for (a = 0; a < ob->totcol; a++)
ob->matbits[a] = (ob->colbits & (1<<a)) != 0;
}
diff --git a/source/blender/blenloader/intern/versioning_legacy.c b/source/blender/blenloader/intern/versioning_legacy.c
index acb9ad581c4..90dd968131a 100644
--- a/source/blender/blenloader/intern/versioning_legacy.c
+++ b/source/blender/blenloader/intern/versioning_legacy.c
@@ -113,7 +113,7 @@ static void vcol_to_fcol(Mesh *me)
if (me->totface == 0 || me->mcol == NULL)
return;
- mcoln = mcolmain = MEM_mallocN(4*sizeof(int)*me->totface, "mcoln");
+ mcoln = mcolmain = MEM_malloc_arrayN(me->totface, 4 * sizeof(int), "mcoln");
mcol = (unsigned int *)me->mcol;
mface = me->mface;
for (a = me->totface; a > 0; a--, mface++) {