Skip to content

Commit

Permalink
[Issue darktable-org#6134] Prevent corrupt collect module presets fro…
Browse files Browse the repository at this point in the history
…m causing a crash
  • Loading branch information
matt-maguire authored and TurboGit committed Sep 1, 2020
1 parent d4bbb07 commit bb23256
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/libs/collect.c
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,11 @@ void *legacy_params(struct dt_lib_module_t *self,
{
/* from v1 to v2 we have reordered the filters */
dt_lib_collect_params_t *o = (dt_lib_collect_params_t *)old_params;

if(o->rules > MAX_RULES)
/* preset is corrupted, return NULL and drop the preset */
return NULL;

dt_lib_collect_params_t *n = (dt_lib_collect_params_t *)malloc(old_params_size);

const int table[DT_COLLECTION_PROP_LAST] =
Expand Down Expand Up @@ -177,6 +182,11 @@ void *legacy_params(struct dt_lib_module_t *self,
{
/* from v2 to v3 we have added 4 new timestamp filters and 2 metadata filters */
dt_lib_collect_params_t *old = (dt_lib_collect_params_t *)old_params;

if(old->rules > MAX_RULES)
/* preset is corrupted, return NULL and drop the preset */
return NULL;

dt_lib_collect_params_t *new = (dt_lib_collect_params_t *)malloc(old_params_size);

const int table[DT_COLLECTION_PROP_LAST] =
Expand Down

0 comments on commit bb23256

Please sign in to comment.