diff options
author | Campbell Barton <ideasman42@gmail.com> | 2009-12-22 13:04:15 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2009-12-22 13:04:15 +0300 |
commit | e207d045322db4656f42f68ae9fa092ac1478635 (patch) | |
tree | 7126490a68ff55d12a9197f1cabd3cf8e0c3b527 /source/blender/makesrna | |
parent | 8f5b2e946bd24cc4ee2b7496b1e022cb24f56f4f (diff) |
quite a few python panels (10 or so) had names longer then the PanelType allowed,
for panels it would fail silently but for menu's it meant further references would give errors.
increase the registered class name from 32 to 64 and raise an error if the limit reached.
Diffstat (limited to 'source/blender/makesrna')
-rw-r--r-- | source/blender/makesrna/intern/rna_ID.c | 9 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_render.c | 7 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_ui.c | 17 |
3 files changed, 31 insertions, 2 deletions
diff --git a/source/blender/makesrna/intern/rna_ID.c b/source/blender/makesrna/intern/rna_ID.c index 2aeb600bc42..a250f0a49b4 100644 --- a/source/blender/makesrna/intern/rna_ID.c +++ b/source/blender/makesrna/intern/rna_ID.c @@ -205,6 +205,15 @@ StructRNA *rna_IDPropertyGroup_register(const bContext *C, ReportList *reports, if(validate(&dummyptr, data, NULL) != 0) return NULL; + /* note: it looks like there is no length limit on the srna id since its + * just a char pointer, but take care here, also be careful that python + * owns the string pointer which it could potentually free while blender + * is running. */ + if(strlen(identifier) >= sizeof(((IDProperty *)NULL)->name)) { + BKE_reportf(reports, RPT_ERROR, "registering id property class: '%s' is too long, maximum length is %d.", identifier, sizeof(((IDProperty *)NULL)->name)); + return NULL; + } + return RNA_def_struct(&BLENDER_RNA, identifier, "IDPropertyGroup"); // XXX } diff --git a/source/blender/makesrna/intern/rna_render.c b/source/blender/makesrna/intern/rna_render.c index 5a80db74c38..8212423acd5 100644 --- a/source/blender/makesrna/intern/rna_render.c +++ b/source/blender/makesrna/intern/rna_render.c @@ -125,7 +125,12 @@ static StructRNA *rna_RenderEngine_register(const bContext *C, ReportList *repor /* validate the python class */ if(validate(&dummyptr, data, have_function) != 0) return NULL; - + + if(strlen(identifier) >= sizeof(dummyet.idname)) { + BKE_reportf(reports, RPT_ERROR, "registering render engine class: '%s' is too long, maximum length is %d.", identifier, sizeof(dummyet.idname)); + return NULL; + } + /* check if we have registered this engine type before, and remove it */ for(et=R_engines.first; et; et=et->next) { if(strcmp(et->idname, dummyet.idname) == 0) { diff --git a/source/blender/makesrna/intern/rna_ui.c b/source/blender/makesrna/intern/rna_ui.c index d33e96df2e6..cbd524680c1 100644 --- a/source/blender/makesrna/intern/rna_ui.c +++ b/source/blender/makesrna/intern/rna_ui.c @@ -163,6 +163,11 @@ static StructRNA *rna_Panel_register(const bContext *C, ReportList *reports, voi /* validate the python class */ if(validate(&dummyptr, data, have_function) != 0) return NULL; + + if(strlen(identifier) >= sizeof(dummypt.idname)) { + BKE_reportf(reports, RPT_ERROR, "registering panel class: '%s' is too long, maximum length is %d.", identifier, sizeof(dummypt.idname)); + return NULL; + } if(!(art=region_type_find(reports, dummypt.space_type, dummypt.region_type))) return NULL; @@ -260,7 +265,12 @@ static StructRNA *rna_Header_register(const bContext *C, ReportList *reports, vo /* validate the python class */ if(validate(&dummyhtr, data, have_function) != 0) return NULL; - + + if(strlen(identifier) >= sizeof(dummyht.idname)) { + BKE_reportf(reports, RPT_ERROR, "registering header class: '%s' is too long, maximum length is %d.", identifier, sizeof(dummyht.idname)); + return NULL; + } + if(!(art=region_type_find(reports, dummyht.space_type, RGN_TYPE_HEADER))) return NULL; @@ -373,6 +383,11 @@ static StructRNA *rna_Menu_register(const bContext *C, ReportList *reports, void /* validate the python class */ if(validate(&dummymtr, data, have_function) != 0) return NULL; + + if(strlen(identifier) >= sizeof(dummymt.idname)) { + BKE_reportf(reports, RPT_ERROR, "registering menu class: '%s' is too long, maximum length is %d.", identifier, sizeof(dummymt.idname)); + return NULL; + } /* check if we have registered this menu type before, and remove it */ mt= WM_menutype_find(dummymt.idname, TRUE); |