## 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-rev1687-g16bd902cb-master
```

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

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

## Pocs

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


## Crash output

```
==21109==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x606000001f18 at pc 0x0000008236c0 bp 0x7fff8b60e4b0 sp 0x7fff8b60e4a8
WRITE of size 2 at 0x606000001f18 thread T0
    #0 0x8236bf in gf_isom_clone_sample_description /programs/mp4box/builds/build6/src/isomedia/isom_write.c:4355:51
    #1 0xd774b5 in mp4_mux_cenc_update /programs/mp4box/builds/build6/src/filters/mux_isom.c:3564:8
    #2 0xd6ab36 in mp4_mux_config_timing /programs/mp4box/builds/build6/src/filters/mux_isom.c:5863:6
    #3 0xd6ab36 in mp4_mux_process /programs/mp4box/builds/build6/src/filters/mux_isom.c:6033:3
    #4 0xb7c2ae in gf_filter_process_task /programs/mp4box/builds/build6/src/filter_core/filter.c:2515:7
    #5 0xb5d7eb in gf_fs_thread_proc /programs/mp4box/builds/build6/src/filter_core/filter_session.c:1756:3
    #6 0xb5c694 in gf_fs_run /programs/mp4box/builds/build6/src/filter_core/filter_session.c:2000:2
    #7 0x910850 in gf_media_fragment_file /programs/mp4box/builds/build6/src/media_tools/isom_tools.c:3816:6
    #8 0x4e6fcc in mp4boxMain /programs/mp4box/builds/build6/applications/mp4box/main.c:6455:7
    #9 0x7fdce2d3b0b2 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x270b2)
    #10 0x41ea6d in _start (/programs/mp4box/builds/build6/bin/gcc/MP4Box+0x41ea6d)

0x606000001f18 is located 0 bytes to the right of 56-byte region [0x606000001ee0,0x606000001f18)
allocated by thread T0 here:
    #0 0x499ccd in malloc (/programs/mp4box/builds/build6/bin/gcc/MP4Box+0x499ccd)
    #1 0x12c089f in unkn_box_new /programs/mp4box/builds/build6/src/isomedia/box_code_base.c:804:2
    #2 0x7af0c1 in gf_isom_box_new_ex /programs/mp4box/builds/build6/src/isomedia/box_funcs.c:1677:17
    #3 0x7ad48d in gf_isom_box_parse_ex /programs/mp4box/builds/build6/src/isomedia/box_funcs.c:240:12
    #4 0x823151 in gf_isom_clone_sample_description /programs/mp4box/builds/build6/src/isomedia/isom_write.c:4336:6
    #5 0xd774b5 in mp4_mux_cenc_update /programs/mp4box/builds/build6/src/filters/mux_isom.c:3564:8
    #6 0xd6ab36 in mp4_mux_config_timing /programs/mp4box/builds/build6/src/filters/mux_isom.c:5863:6
    #7 0xd6ab36 in mp4_mux_process /programs/mp4box/builds/build6/src/filters/mux_isom.c:6033:3
    #8 0xb7c2ae in gf_filter_process_task /programs/mp4box/builds/build6/src/filter_core/filter.c:2515:7
    #9 0xb5d7eb in gf_fs_thread_proc /programs/mp4box/builds/build6/src/filter_core/filter_session.c:1756:3
    #10 0xb5c694 in gf_fs_run /programs/mp4box/builds/build6/src/filter_core/filter_session.c:2000:2
    #11 0x910850 in gf_media_fragment_file /programs/mp4box/builds/build6/src/media_tools/isom_tools.c:3816:6
    #12 0x4e6fcc in mp4boxMain /programs/mp4box/builds/build6/applications/mp4box/main.c:6455:7
    #13 0x7fdce2d3b0b2 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x270b2)

SUMMARY: AddressSanitizer: heap-buffer-overflow /programs/mp4box/builds/build6/src/isomedia/isom_write.c:4355:51 in gf_isom_clone_sample_description
Shadow bytes around the buggy address:
  0x0c0c7fff8390: fa fa fa fa 00 00 00 00 00 00 00 fa fa fa fa fa
  0x0c0c7fff83a0: fd fd fd fd fd fd fd fd fa fa fa fa fd fd fd fd
  0x0c0c7fff83b0: fd fd fd fa fa fa fa fa fd fd fd fd fd fd fd fd
  0x0c0c7fff83c0: fa fa fa fa fd fd fd fd fd fd fd fd fa fa fa fa
  0x0c0c7fff83d0: 00 00 00 00 00 00 00 00 fa fa fa fa 00 00 00 00
=>0x0c0c7fff83e0: 00 00 00[fa]fa fa fa fa fa fa fa fa fa fa fa fa
  0x0c0c7fff83f0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0c0c7fff8400: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0c0c7fff8410: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0c0c7fff8420: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0c0c7fff8430: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa 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
==21109==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-rev1687-g16bd902cb-master
```

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

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

## Pocs

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


## Crash output

```
==21109==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x606000001f18 at pc 0x0000008236c0 bp 0x7fff8b60e4b0 sp 0x7fff8b60e4a8
WRITE of size 2 at 0x606000001f18 thread T0
    #0 0x8236bf in gf_isom_clone_sample_description /programs/mp4box/builds/build6/src/isomedia/isom_write.c:4355:51
    #1 0xd774b5 in mp4_mux_cenc_update /programs/mp4box/builds/build6/src/filters/mux_isom.c:3564:8
    #2 0xd6ab36 in mp4_mux_config_timing /programs/mp4box/builds/build6/src/filters/mux_isom.c:5863:6
    #3 0xd6ab36 in mp4_mux_process /programs/mp4box/builds/build6/src/filters/mux_isom.c:6033:3
    #4 0xb7c2ae in gf_filter_process_task /programs/mp4box/builds/build6/src/filter_core/filter.c:2515:7
    #5 0xb5d7eb in gf_fs_thread_proc /programs/mp4box/builds/build6/src/filter_core/filter_session.c:1756:3
    #6 0xb5c694 in gf_fs_run /programs/mp4box/builds/build6/src/filter_core/filter_session.c:2000:2
    #7 0x910850 in gf_media_fragment_file /programs/mp4box/builds/build6/src/media_tools/isom_tools.c:3816:6
    #8 0x4e6fcc in mp4boxMain /programs/mp4box/builds/build6/applications/mp4box/main.c:6455:7
    #9 0x7fdce2d3b0b2 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x270b2)
    #10 0x41ea6d in _start (/programs/mp4box/builds/build6/bin/gcc/MP4Box+0x41ea6d)

0x606000001f18 is located 0 bytes to the right of 56-byte region [0x606000001ee0,0x606000001f18)
allocated by thread T0 here:
    #0 0x499ccd in malloc (/programs/mp4box/builds/build6/bin/gcc/MP4Box+0x499ccd)
    #1 0x12c089f in unkn_box_new /programs/mp4box/builds/build6/src/isomedia/box_code_base.c:804:2
    #2 0x7af0c1 in gf_isom_box_new_ex /programs/mp4box/builds/build6/src/isomedia/box_funcs.c:1677:17
    #3 0x7ad48d in gf_isom_box_parse_ex /programs/mp4box/builds/build6/src/isomedia/box_funcs.c:240:12
    #4 0x823151 in gf_isom_clone_sample_description /programs/mp4box/builds/build6/src/isomedia/isom_write.c:4336:6
    #5 0xd774b5 in mp4_mux_cenc_update /programs/mp4box/builds/build6/src/filters/mux_isom.c:3564:8
    #6 0xd6ab36 in mp4_mux_config_timing /programs/mp4box/builds/build6/src/filters/mux_isom.c:5863:6
    #7 0xd6ab36 in mp4_mux_process /programs/mp4box/builds/build6/src/filters/mux_isom.c:6033:3
    #8 0xb7c2ae in gf_filter_process_task /programs/mp4box/builds/build6/src/filter_core/filter.c:2515:7
    #9 0xb5d7eb in gf_fs_thread_proc /programs/mp4box/builds/build6/src/filter_core/filter_session.c:1756:3
    #10 0xb5c694 in gf_fs_run /programs/mp4box/builds/build6/src/filter_core/filter_session.c:2000:2
    #11 0x910850 in gf_media_fragment_file /programs/mp4box/builds/build6/src/media_tools/isom_tools.c:3816:6
    #12 0x4e6fcc in mp4boxMain /programs/mp4box/builds/build6/applications/mp4box/main.c:6455:7
    #13 0x7fdce2d3b0b2 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x270b2)

SUMMARY: AddressSanitizer: heap-buffer-overflow /programs/mp4box/builds/build6/src/isomedia/isom_write.c:4355:51 in gf_isom_clone_sample_description
Shadow bytes around the buggy address:
  0x0c0c7fff8390: fa fa fa fa 00 00 00 00 00 00 00 fa fa fa fa fa
  0x0c0c7fff83a0: fd fd fd fd fd fd fd fd fa fa fa fa fd fd fd fd
  0x0c0c7fff83b0: fd fd fd fa fa fa fa fa fd fd fd fd fd fd fd fd
  0x0c0c7fff83c0: fa fa fa fa fd fd fd fd fd fd fd fd fa fa fa fa
  0x0c0c7fff83d0: 00 00 00 00 00 00 00 00 fa fa fa fa 00 00 00 00
=>0x0c0c7fff83e0: 00 00 00[fa]fa fa fa fa fa fa fa fa fa fa fa fa
  0x0c0c7fff83f0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0c0c7fff8400: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0c0c7fff8410: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0c0c7fff8420: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0c0c7fff8430: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa 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
==21109==ABORTING
------------------------
```
--- end body ---
