File tree Expand file tree Collapse file tree 1 file changed +10
-2
lines changed
Expand file tree Collapse file tree 1 file changed +10
-2
lines changed Original file line number Diff line number Diff line change @@ -397,13 +397,21 @@ SAIL_EXPORT sail_status_t sail_codec_save_seek_next_frame_v8_fli(void* state, co
397397 /* Determine if we're writing FLI or FLC. */
398398 fli_state -> is_fli = (image -> width == 320 && image -> height == 200 );
399399
400+ /* Validate dimensions fit in uint16_t. */
401+ if (image -> width > UINT16_MAX || image -> height > UINT16_MAX )
402+ {
403+ SAIL_LOG_ERROR ("FLI: Image dimensions %ux%u exceed maximum allowed (%ux%u)" ,
404+ image -> width , image -> height , UINT16_MAX , UINT16_MAX );
405+ SAIL_LOG_AND_RETURN (SAIL_ERROR_INVALID_IMAGE );
406+ }
407+
400408 /* Fill FLI header. */
401409 memset (& fli_state -> fli_header , 0 , sizeof (fli_state -> fli_header ));
402410 fli_state -> fli_header .size = 0 ;
403411 fli_state -> fli_header .magic = fli_state -> is_fli ? SAIL_FLI_MAGIC : SAIL_FLC_MAGIC ;
404412 fli_state -> fli_header .frames = 0 ;
405- fli_state -> fli_header .width = image -> width ;
406- fli_state -> fli_header .height = image -> height ;
413+ fli_state -> fli_header .width = ( uint16_t ) image -> width ;
414+ fli_state -> fli_header .height = ( uint16_t ) image -> height ;
407415 fli_state -> fli_header .depth = 8 ;
408416 fli_state -> fli_header .flags = 0 ;
409417
You can’t perform that action at this time.
0 commit comments