## Description
There is a heap buffer overflow detected by AddressSanitizer

## System info
```
Ubuntu 20.04.2 LTS
clang version 12.0.0-++20210402082642+04ba60cfe598-1~exp1~20210402063359.71
MP4Box - GPAC version 1.1.0-DEV-rev1745-g9e1378706-master
```

## Build command
```
./configure --static-mp4box --prefix=`realpath ./install` --enable-sanitizer --cc=clang --cxx=clang++
```

## crash command
```
MP4Box -out /dev/null poc_file
```

## Pocs

[poc.zip](https://github.com/gpac/gpac/files/8039045/poc.zip)


## Crash output

```
==35757==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x602000001270 at pc 0x0000007d0889 bp 0x7fff1400a3d0 sp 0x7fff1400a3c8
READ of size 4 at 0x602000001270 thread T0
    #0 0x7d0888 in convert_compact_sample_groups /programs/mp4box/builds/build13/src/isomedia/isom_intern.c:296:18
    #1 0x7c9018 in gf_isom_parse_movie_boxes_internal /programs/mp4box/builds/build13/src/isomedia/isom_intern.c:420:7
    #2 0x7c9018 in gf_isom_parse_movie_boxes /programs/mp4box/builds/build13/src/isomedia/isom_intern.c:812:6
    #3 0x7ccf16 in gf_isom_open_file /programs/mp4box/builds/build13/src/isomedia/isom_intern.c:932:19
    #4 0x4e14c6 in mp4boxMain /programs/mp4box/builds/build13/applications/mp4box/main.c:5984:12
    #5 0x7fce38d730b2 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x270b2)
    #6 0x41ea6d in _start (/programs/mp4box/builds/build13/bin/gcc/MP4Box+0x41ea6d)

0x602000001271 is located 0 bytes to the right of 1-byte region [0x602000001270,0x602000001271)
allocated by thread T0 here:
    #0 0x499ccd in malloc (/programs/mp4box/builds/build13/bin/gcc/MP4Box+0x499ccd)
    #1 0x1310c8e in csgp_box_read /programs/mp4box/builds/build13/src/isomedia/box_code_base.c:12613:55
    #2 0x7adfad in gf_isom_box_read /programs/mp4box/builds/build13/src/isomedia/box_funcs.c:1822:9
    #3 0x7adfad in gf_isom_box_parse_ex /programs/mp4box/builds/build13/src/isomedia/box_funcs.c:264:14
    #4 0x7afda3 in gf_isom_box_array_read_ex /programs/mp4box/builds/build13/src/isomedia/box_funcs.c:1719:7
    #5 0x12e1c6b in stbl_box_read /programs/mp4box/builds/build13/src/isomedia/box_code_base.c:5069:6
    #6 0x7adfad in gf_isom_box_read /programs/mp4box/builds/build13/src/isomedia/box_funcs.c:1822:9
    #7 0x7adfad in gf_isom_box_parse_ex /programs/mp4box/builds/build13/src/isomedia/box_funcs.c:264:14
    #8 0x7afda3 in gf_isom_box_array_read_ex /programs/mp4box/builds/build13/src/isomedia/box_funcs.c:1719:7
    #9 0x12d7132 in minf_box_read /programs/mp4box/builds/build13/src/isomedia/box_code_base.c:3549:6
    #10 0x7adfad in gf_isom_box_read /programs/mp4box/builds/build13/src/isomedia/box_funcs.c:1822:9
    #11 0x7adfad in gf_isom_box_parse_ex /programs/mp4box/builds/build13/src/isomedia/box_funcs.c:264:14
    #12 0x7afda3 in gf_isom_box_array_read_ex /programs/mp4box/builds/build13/src/isomedia/box_funcs.c:1719:7
    #13 0x12d4665 in mdia_box_read /programs/mp4box/builds/build13/src/isomedia/box_code_base.c:3100:6
    #14 0x7adfad in gf_isom_box_read /programs/mp4box/builds/build13/src/isomedia/box_funcs.c:1822:9
    #15 0x7adfad in gf_isom_box_parse_ex /programs/mp4box/builds/build13/src/isomedia/box_funcs.c:264:14
    #16 0x7afda3 in gf_isom_box_array_read_ex /programs/mp4box/builds/build13/src/isomedia/box_funcs.c:1719:7
    #17 0x12ec620 in trak_box_read /programs/mp4box/builds/build13/src/isomedia/box_code_base.c:6844:6
    #18 0x7adfad in gf_isom_box_read /programs/mp4box/builds/build13/src/isomedia/box_funcs.c:1822:9
    #19 0x7adfad in gf_isom_box_parse_ex /programs/mp4box/builds/build13/src/isomedia/box_funcs.c:264:14
    #20 0x7afda3 in gf_isom_box_array_read_ex /programs/mp4box/builds/build13/src/isomedia/box_funcs.c:1719:7
    #21 0x7adfad in gf_isom_box_read /programs/mp4box/builds/build13/src/isomedia/box_funcs.c:1822:9
    #22 0x7adfad in gf_isom_box_parse_ex /programs/mp4box/builds/build13/src/isomedia/box_funcs.c:264:14
    #23 0x7ad181 in gf_isom_parse_root_box /programs/mp4box/builds/build13/src/isomedia/box_funcs.c:38:8
    #24 0x7c8b31 in gf_isom_parse_movie_boxes_internal /programs/mp4box/builds/build13/src/isomedia/isom_intern.c:349:7
    #25 0x7c8b31 in gf_isom_parse_movie_boxes /programs/mp4box/builds/build13/src/isomedia/isom_intern.c:812:6
    #26 0x7ccf16 in gf_isom_open_file /programs/mp4box/builds/build13/src/isomedia/isom_intern.c:932:19
    #27 0x4e14c6 in mp4boxMain /programs/mp4box/builds/build13/applications/mp4box/main.c:5984:12
    #28 0x7fce38d730b2 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x270b2)

SUMMARY: AddressSanitizer: heap-buffer-overflow /programs/mp4box/builds/build13/src/isomedia/isom_intern.c:296:18 in convert_compact_sample_groups
Shadow bytes around the buggy address:
  0x0c047fff81f0: fa fa 00 00 fa fa 00 00 fa fa 00 00 fa fa 00 00
  0x0c047fff8200: fa fa 00 05 fa fa 00 00 fa fa 00 00 fa fa 00 00
  0x0c047fff8210: fa fa 00 00 fa fa 00 00 fa fa 00 00 fa fa 01 fa
  0x0c047fff8220: fa fa fd fa fa fa fd fd fa fa 00 00 fa fa 00 00
  0x0c047fff8230: fa fa 01 fa fa fa 01 fa fa fa 01 fa fa fa 01 fa
=>0x0c047fff8240: fa fa 01 fa fa fa 01 fa fa fa 01 fa fa fa[01]fa
  0x0c047fff8250: fa fa 01 fa fa fa 01 fa fa fa 01 fa fa fa 01 fa
  0x0c047fff8260: fa fa 01 fa fa fa 01 fa fa fa 01 fa fa fa 01 fa
  0x0c047fff8270: fa fa 01 fa fa fa 01 fa fa fa 01 fa fa fa 01 fa
  0x0c047fff8280: fa fa 01 fa fa fa 01 fa fa fa 01 fa fa fa 00 04
  0x0c047fff8290: fa fa 01 fa fa fa 01 fa fa fa 01 fa fa fa 01 fa
Shadow byte legend (one shadow byte represents 8 application bytes):
  Addressable:           00
  Partially addressable: 01 02 03 04 05 06 07 
  Heap left redzone:       fa
  Freed heap region:       fd
  Stack left redzone:      f1
  Stack mid redzone:       f2
  Stack right redzone:     f3
  Stack after return:      f5
  Stack use after scope:   f8
  Global redzone:          f9
  Global init order:       f6
  Poisoned by user:        f7
  Container overflow:      fc
  Array cookie:            ac
  Intra object redzone:    bb
  ASan internal:           fe
  Left alloca redzone:     ca
  Right alloca redzone:    cb
  Shadow gap:              cc
==35757==ABORTING
```
There is a heap buffer overflow detected by AddressSanitizer
This is a GitHub Issue
repo:gpac
owner:gpac
Title : There is a heap buffer overflow detected by AddressSanitizer
Issue date:

--- start body ---
## Description
There is a heap buffer overflow detected by AddressSanitizer

## System info
```
Ubuntu 20.04.2 LTS
clang version 12.0.0-++20210402082642+04ba60cfe598-1~exp1~20210402063359.71
MP4Box - GPAC version 1.1.0-DEV-rev1745-g9e1378706-master
```

## Build command
```
./configure --static-mp4box --prefix=`realpath ./install` --enable-sanitizer --cc=clang --cxx=clang++
```

## crash command
```
MP4Box -out /dev/null poc_file
```

## Pocs

[poc.zip](https://github.com/gpac/gpac/files/8039045/poc.zip)


## Crash output

```
==35757==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x602000001270 at pc 0x0000007d0889 bp 0x7fff1400a3d0 sp 0x7fff1400a3c8
READ of size 4 at 0x602000001270 thread T0
    #0 0x7d0888 in convert_compact_sample_groups /programs/mp4box/builds/build13/src/isomedia/isom_intern.c:296:18
    #1 0x7c9018 in gf_isom_parse_movie_boxes_internal /programs/mp4box/builds/build13/src/isomedia/isom_intern.c:420:7
    #2 0x7c9018 in gf_isom_parse_movie_boxes /programs/mp4box/builds/build13/src/isomedia/isom_intern.c:812:6
    #3 0x7ccf16 in gf_isom_open_file /programs/mp4box/builds/build13/src/isomedia/isom_intern.c:932:19
    #4 0x4e14c6 in mp4boxMain /programs/mp4box/builds/build13/applications/mp4box/main.c:5984:12
    #5 0x7fce38d730b2 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x270b2)
    #6 0x41ea6d in _start (/programs/mp4box/builds/build13/bin/gcc/MP4Box+0x41ea6d)

0x602000001271 is located 0 bytes to the right of 1-byte region [0x602000001270,0x602000001271)
allocated by thread T0 here:
    #0 0x499ccd in malloc (/programs/mp4box/builds/build13/bin/gcc/MP4Box+0x499ccd)
    #1 0x1310c8e in csgp_box_read /programs/mp4box/builds/build13/src/isomedia/box_code_base.c:12613:55
    #2 0x7adfad in gf_isom_box_read /programs/mp4box/builds/build13/src/isomedia/box_funcs.c:1822:9
    #3 0x7adfad in gf_isom_box_parse_ex /programs/mp4box/builds/build13/src/isomedia/box_funcs.c:264:14
    #4 0x7afda3 in gf_isom_box_array_read_ex /programs/mp4box/builds/build13/src/isomedia/box_funcs.c:1719:7
    #5 0x12e1c6b in stbl_box_read /programs/mp4box/builds/build13/src/isomedia/box_code_base.c:5069:6
    #6 0x7adfad in gf_isom_box_read /programs/mp4box/builds/build13/src/isomedia/box_funcs.c:1822:9
    #7 0x7adfad in gf_isom_box_parse_ex /programs/mp4box/builds/build13/src/isomedia/box_funcs.c:264:14
    #8 0x7afda3 in gf_isom_box_array_read_ex /programs/mp4box/builds/build13/src/isomedia/box_funcs.c:1719:7
    #9 0x12d7132 in minf_box_read /programs/mp4box/builds/build13/src/isomedia/box_code_base.c:3549:6
    #10 0x7adfad in gf_isom_box_read /programs/mp4box/builds/build13/src/isomedia/box_funcs.c:1822:9
    #11 0x7adfad in gf_isom_box_parse_ex /programs/mp4box/builds/build13/src/isomedia/box_funcs.c:264:14
    #12 0x7afda3 in gf_isom_box_array_read_ex /programs/mp4box/builds/build13/src/isomedia/box_funcs.c:1719:7
    #13 0x12d4665 in mdia_box_read /programs/mp4box/builds/build13/src/isomedia/box_code_base.c:3100:6
    #14 0x7adfad in gf_isom_box_read /programs/mp4box/builds/build13/src/isomedia/box_funcs.c:1822:9
    #15 0x7adfad in gf_isom_box_parse_ex /programs/mp4box/builds/build13/src/isomedia/box_funcs.c:264:14
    #16 0x7afda3 in gf_isom_box_array_read_ex /programs/mp4box/builds/build13/src/isomedia/box_funcs.c:1719:7
    #17 0x12ec620 in trak_box_read /programs/mp4box/builds/build13/src/isomedia/box_code_base.c:6844:6
    #18 0x7adfad in gf_isom_box_read /programs/mp4box/builds/build13/src/isomedia/box_funcs.c:1822:9
    #19 0x7adfad in gf_isom_box_parse_ex /programs/mp4box/builds/build13/src/isomedia/box_funcs.c:264:14
    #20 0x7afda3 in gf_isom_box_array_read_ex /programs/mp4box/builds/build13/src/isomedia/box_funcs.c:1719:7
    #21 0x7adfad in gf_isom_box_read /programs/mp4box/builds/build13/src/isomedia/box_funcs.c:1822:9
    #22 0x7adfad in gf_isom_box_parse_ex /programs/mp4box/builds/build13/src/isomedia/box_funcs.c:264:14
    #23 0x7ad181 in gf_isom_parse_root_box /programs/mp4box/builds/build13/src/isomedia/box_funcs.c:38:8
    #24 0x7c8b31 in gf_isom_parse_movie_boxes_internal /programs/mp4box/builds/build13/src/isomedia/isom_intern.c:349:7
    #25 0x7c8b31 in gf_isom_parse_movie_boxes /programs/mp4box/builds/build13/src/isomedia/isom_intern.c:812:6
    #26 0x7ccf16 in gf_isom_open_file /programs/mp4box/builds/build13/src/isomedia/isom_intern.c:932:19
    #27 0x4e14c6 in mp4boxMain /programs/mp4box/builds/build13/applications/mp4box/main.c:5984:12
    #28 0x7fce38d730b2 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x270b2)

SUMMARY: AddressSanitizer: heap-buffer-overflow /programs/mp4box/builds/build13/src/isomedia/isom_intern.c:296:18 in convert_compact_sample_groups
Shadow bytes around the buggy address:
  0x0c047fff81f0: fa fa 00 00 fa fa 00 00 fa fa 00 00 fa fa 00 00
  0x0c047fff8200: fa fa 00 05 fa fa 00 00 fa fa 00 00 fa fa 00 00
  0x0c047fff8210: fa fa 00 00 fa fa 00 00 fa fa 00 00 fa fa 01 fa
  0x0c047fff8220: fa fa fd fa fa fa fd fd fa fa 00 00 fa fa 00 00
  0x0c047fff8230: fa fa 01 fa fa fa 01 fa fa fa 01 fa fa fa 01 fa
=>0x0c047fff8240: fa fa 01 fa fa fa 01 fa fa fa 01 fa fa fa[01]fa
  0x0c047fff8250: fa fa 01 fa fa fa 01 fa fa fa 01 fa fa fa 01 fa
  0x0c047fff8260: fa fa 01 fa fa fa 01 fa fa fa 01 fa fa fa 01 fa
  0x0c047fff8270: fa fa 01 fa fa fa 01 fa fa fa 01 fa fa fa 01 fa
  0x0c047fff8280: fa fa 01 fa fa fa 01 fa fa fa 01 fa fa fa 00 04
  0x0c047fff8290: fa fa 01 fa fa fa 01 fa fa fa 01 fa fa fa 01 fa
Shadow byte legend (one shadow byte represents 8 application bytes):
  Addressable:           00
  Partially addressable: 01 02 03 04 05 06 07 
  Heap left redzone:       fa
  Freed heap region:       fd
  Stack left redzone:      f1
  Stack mid redzone:       f2
  Stack right redzone:     f3
  Stack after return:      f5
  Stack use after scope:   f8
  Global redzone:          f9
  Global init order:       f6
  Poisoned by user:        f7
  Container overflow:      fc
  Array cookie:            ac
  Intra object redzone:    bb
  ASan internal:           fe
  Left alloca redzone:     ca
  Right alloca redzone:    cb
  Shadow gap:              cc
==35757==ABORTING
```
--- end body ---
