Skip to content

Commit

Permalink
add command-line option for heif-dec 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 1726a36 commit 47e00f2
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion examples/heif_dec.cc
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,8 @@ static void show_help(const char* argv0)
" --tiles output all image tiles as separate images\n"
" --quiet do not output status messages to console\n"
" -C, --chroma-upsampling ALGO Force chroma upsampling algorithm (nn = nearest-neighbor / bilinear)\n"
" --png-compression-level # Set to integer between 0 (fastest) and 9 (best). Use -1 for default.\n";
" --png-compression-level # Set to integer between 0 (fastest) and 9 (best). Use -1 for default.\n"
" --disable-limits disable all security limits (do not use in production environment)\n";
}


Expand Down Expand Up @@ -123,6 +124,7 @@ int option_skip_exif_offset = 0;
int option_list_decoders = 0;
int option_png_compression_level = -1; // use zlib default
int option_output_tiles = 0;
int option_disable_limits = 0;
std::string output_filename;

std::string chroma_upsampling;
Expand All @@ -147,6 +149,7 @@ static struct option long_options[] = {
{(char* const) "chroma-upsampling", required_argument, 0, 'C'},
{(char* const) "png-compression-level", required_argument, 0, OPTION_PNG_COMPRESSION_LEVEL},
{(char* const) "version", no_argument, 0, 'v'},
{(char* const) "disable-limits", no_argument, &option_disable_limits, 1},
{nullptr, no_argument, nullptr, 0}
};

Expand Down Expand Up @@ -794,6 +797,10 @@ int main(int argc, char** argv)
return 1;
}

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

ContextReleaser cr(ctx);
struct heif_error err;
err = heif_context_read_from_file(ctx, input_filename.c_str(), nullptr);
Expand Down

0 comments on commit 47e00f2

Please sign in to comment.