Skip to content

Commit

Permalink
add command-line option for heif-info to disable security limits
Browse files Browse the repository at this point in the history
  • Loading branch information
farindk committed Oct 28, 2024
1 parent 166d77f commit 0389bd4
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
8 changes: 8 additions & 0 deletions examples/heif_info.cc
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,13 @@ info -w 20012 -o out.265 *file
info -d // dump
*/

int option_disable_limits = 0;

static struct option long_options[] = {
//{"write-raw", required_argument, 0, 'w' },
//{"output", required_argument, 0, 'o' },
{(char* const) "dump-boxes", no_argument, 0, 'd'},
{(char* const) "disable-limits", no_argument, &option_disable_limits, 1},
{(char* const) "help", no_argument, 0, 'h'},
{(char* const) "version", no_argument, 0, 'v'},
{0, 0, 0, 0}
Expand All @@ -95,6 +98,7 @@ void show_help(const char* argv0)
//fprintf(stderr," -w, --write-raw ID write raw compressed data of image 'ID'\n");
//fprintf(stderr," -o, --output NAME output file name for image selected by -w\n");
fprintf(stderr, " -d, --dump-boxes show a low-level dump of all MP4 file boxes\n");
fprintf(stderr, " --disable-limits disable all security limits (do not use in production environment)\n");
fprintf(stderr, " -h, --help show help\n");
fprintf(stderr, " -v, --version show version\n");
}
Expand Down Expand Up @@ -221,6 +225,10 @@ int main(int argc, char** argv)
return 1;
}

if (option_disable_limits) {
heif_context_set_security_limits(ctx.get(), heif_get_disabled_security_limits());
}

struct heif_error err;
err = heif_context_read_from_file(ctx.get(), input_filename, nullptr);

Expand Down
1 change: 1 addition & 0 deletions libheif/context.cc
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ static void copy_security_limits(heif_security_limits* dst, const heif_security_
dst->max_memory_block_size = src->max_memory_block_size;

dst->max_components = src->max_components;

dst->max_iloc_extents_per_item = src->max_iloc_extents_per_item;
dst->max_size_entity_group = src->max_size_entity_group;

Expand Down

0 comments on commit 0389bd4

Please sign in to comment.