Skip to content

Commit

Permalink
[WiP] heifload: disable all security limits with unlimited
Browse files Browse the repository at this point in the history
Also, increase the default maximum image size to 32768^2 to align
with libheif's defaults.

See:
strukturag/libheif#1389
strukturag/libheif#1359 (comment)
  • Loading branch information
kleisauke committed Nov 17, 2024
1 parent e38953c commit 5bf7cc6
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
2 changes: 2 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

- add `keep_duplicate_frames` option to GIF save [dloebl]
- add Magic Kernel support [akimon658]
- heifload: increase maximum image size to 32768^2 [kleisauke]
- heifload: "unlimited" flag disables all security limits [kleisauke]

8.16.1

Expand Down
10 changes: 7 additions & 3 deletions libvips/foreign/heifload.c
Original file line number Diff line number Diff line change
Expand Up @@ -350,10 +350,14 @@ vips_foreign_load_heif_build(VipsObject *object)
struct heif_error error;

heif->ctx = heif_context_alloc();
#ifdef HAVE_HEIF_SET_MAX_IMAGE_SIZE_LIMIT
#ifdef HAVE_HEIF_CONTEXT_SET_SECURITY_LIMITS
if (heif->unlimited)
heif_context_set_security_limits(heif->ctx,
heif_get_disabled_security_limits());
#elif defined(HAVE_HEIF_SET_MAX_IMAGE_SIZE_LIMIT)
heif_context_set_maximum_image_size_limit(heif->ctx,
heif->unlimited ? USHRT_MAX : 0x4000);
#endif /* HAVE_HEIF_SET_MAX_IMAGE_SIZE_LIMIT */
heif->unlimited ? USHRT_MAX : 0x8000);
#endif /* HAVE_HEIF_CONTEXT_SET_SECURITY_LIMITS */
error = heif_context_read_from_reader(heif->ctx,
heif->reader, heif, NULL);
if (error.code) {
Expand Down
4 changes: 4 additions & 0 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -568,6 +568,10 @@ if libheif_dep.found()
if libheif_dep.version().version_compare('>=1.17.0')
cfg_var.set('HAVE_HEIF_ERROR_SUCCESS', '1')
endif
# heif_context_set_security_limits added in 1.19.0
if libheif_dep.version().version_compare('>=1.19.0')
cfg_var.set('HAVE_HEIF_CONTEXT_SET_SECURITY_LIMITS', '1')
endif
endif

libjxl_dep = dependency('libjxl', version: '>=0.6', required: get_option('jpeg-xl'))
Expand Down

0 comments on commit 5bf7cc6

Please sign in to comment.