Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 7784143

Browse files
authored
heif{load,save}: guard against NULL strings (libvips#3608)
Ensures that a `NULL` string is never passed to `vsnprintf`, avoiding the occurrence of undefined behavior (UB). Resolves: libvips#3588.
1 parent e091d65 commit 7784143

File tree

3 files changed

+9
-5
lines changed

3 files changed

+9
-5
lines changed

ChangeLog

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
TBD 8.14.4
22

33
- fix null-pointer dereference during svgload [kleisauke]
4+
- heif{load,save}: guard against NULL strings [kleisauke]
45

56
20/7/23 8.14.3
67

libvips/foreign/heifload.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -213,8 +213,9 @@ void
213213
vips__heif_error( struct heif_error *error )
214214
{
215215
if( error->code )
216-
vips_error( "heif", "%s (%d.%d)", error->message, error->code,
217-
error->subcode );
216+
vips_error( "heif", "%s (%d.%d)",
217+
error->message ? error->message : "(null)",
218+
error->code, error->subcode );
218219
}
219220

220221
typedef struct _VipsForeignLoadHeifClass {

libvips/foreign/heifsave.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -426,9 +426,11 @@ vips_foreign_save_heif_write( struct heif_context *ctx,
426426

427427
struct heif_error error;
428428

429-
error.code = 0;
430-
if( vips_target_write( heif->target, data, length ) )
431-
error.code = -1;
429+
error.code = heif_error_Ok;
430+
if( vips_target_write( heif->target, data, length ) ) {
431+
error.code = heif_error_Encoding_error;
432+
error.subcode = heif_suberror_Cannot_write_output_data;
433+
}
432434

433435
return( error );
434436
}

0 commit comments

Comments
 (0)