Skip to content

Address sanitizer issue with `IND_LIST_DYN`

Basic info

Bug description

Clang ASAN error:

ivas_qmetadata_enc.c
Heap-buffer-overflow on address 0x621000001328 at pc 0x000000627d2e bp 0x7ffedc295280 sp 0x7ffedc295278
WRITE of size 2 at 0x621000001328 thread T0
0x627d2d restore_metadata_buffer ivas_qmetadata_enc.c:2230 
0x613c35 ivas_qmetadata_enc_encode ivas_qmetadata_enc.c:512 
0x5a7ccc ivas_masa_encode ivas_masa_enc.c:341 
0x580516 ivas_enc ivas_enc.c:235 
0x5092c4 IVAS_ENC_EncodeFrameToSerial lib_enc.c:1265 
0x4f6433 main encoder.c:744 
0x7fcc1f2c6082 __libc_start_main libc-start.c:308 
0x44257d _start 
Allocated by thread T0 here:
0x4bed2d __interceptor_malloc 
0x584ba8 ivas_init_encoder ivas_init_enc.c:393 
0x5027f0 configureEncoder lib_enc.c:928 
0x5059b0 IVAS_ENC_ConfigureForMasa lib_enc.c:575 
0x4f3786 main encoder.c:416 
0x7fcc1f2c6082 __libc_start_main libc-start.c:308

Ways to reproduce

Encoding such MASA content that the metadata indices reach ivas_max_num_indices.

Analysis

Error is present when switch IND_LIST_DYN is enabled.

Instead of raising the assertion error mentioned in #502 (closed), the processing occasionally enters undefined behaviour here. As a symptom, the processing result differs on Mac and Linux.

I would suspect that the upper limit of the loop for ( i = next_ind_start; i <= hMetaData->nb_ind_tot; i++ ) should not include the equality.