## 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-rev1727-g8be34973d-master
```

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

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

## Pocs
[poc.zip](https://github.com/gpac/gpac/files/8020674/poc.zip)

## Crash output

```
==10522==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x611000001009 at pc 0x0000004f4e0b bp 0x7ffcd88db5d0 sp 0x7ffcd88db5c8
READ of size 1 at 0x611000001009 thread T0
    #0 0x4f4e0a in read_nal_size_hdr/programs/mp4box/builds/build10/applications/mp4box/filedump.c:1007:20
    #1 0x4f4e0a in dump_isom_nal_ex/programs/mp4box/builds/build10/applications/mp4box/filedump.c:1271:15
    #2 0x4f8170 in dump_isom_xml/programs/mp4box/builds/build10/applications/mp4box/filedump.c:2001:9
    #3 0x4e0da8 in mp4boxMain/programs/mp4box/builds/build10/applications/mp4box/main.c:6171:7
    #4 0x7fa1487680b2 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x270b2)
    #5 0x41ea6d in _start (/zhengjie/cmdline-fuzz/programs/mp4box/builds/build10/bin/gcc/MP4Box+0x41ea6d)

0x611000001009 is located 0 bytes to the right of 201-byte region [0x611000000f40,0x611000001009)
allocated by thread T0 here:
    #0 0x499ccd in malloc (/zhengjie/cmdline-fuzz/programs/mp4box/builds/build10/bin/gcc/MP4Box+0x499ccd)
    #1 0x841fd9 in Media_GetSample/programs/mp4box/builds/build10/src/isomedia/media.c:625:29
    #2 0x7d9fd0 in gf_isom_get_sample_ex/programs/mp4box/builds/build10/src/isomedia/isom_read.c:1905:6
    #3 0x4f40a0 in dump_isom_nal_ex/programs/mp4box/builds/build10/applications/mp4box/filedump.c:1234:24
    #4 0x4f8170 in dump_isom_xml/programs/mp4box/builds/build10/applications/mp4box/filedump.c:2001:9
    #5 0x4e0da8 in mp4boxMain/programs/mp4box/builds/build10/applications/mp4box/main.c:6171:7
    #6 0x7fa1487680b2 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x270b2)

SUMMARY: AddressSanitizer: heap-buffer-overflow/programs/mp4box/builds/build10/applications/mp4box/filedump.c:1007:20 in read_nal_size_hdr
Shadow bytes around the buggy address:
  0x0c227fff81b0: 00 00 00 00 00 00 00 fa fa fa fa fa fa fa fa fa
  0x0c227fff81c0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x0c227fff81d0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 fa fa
  0x0c227fff81e0: fa fa fa fa fa fa fa fa 00 00 00 00 00 00 00 00
  0x0c227fff81f0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
=>0x0c227fff8200: 00[01]fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0c227fff8210: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0c227fff8220: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0c227fff8230: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0c227fff8240: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0c227fff8250: 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
==10522==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-rev1727-g8be34973d-master
```

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

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

## Pocs
[poc.zip](https://github.com/gpac/gpac/files/8020674/poc.zip)

## Crash output

```
==10522==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x611000001009 at pc 0x0000004f4e0b bp 0x7ffcd88db5d0 sp 0x7ffcd88db5c8
READ of size 1 at 0x611000001009 thread T0
    #0 0x4f4e0a in read_nal_size_hdr/programs/mp4box/builds/build10/applications/mp4box/filedump.c:1007:20
    #1 0x4f4e0a in dump_isom_nal_ex/programs/mp4box/builds/build10/applications/mp4box/filedump.c:1271:15
    #2 0x4f8170 in dump_isom_xml/programs/mp4box/builds/build10/applications/mp4box/filedump.c:2001:9
    #3 0x4e0da8 in mp4boxMain/programs/mp4box/builds/build10/applications/mp4box/main.c:6171:7
    #4 0x7fa1487680b2 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x270b2)
    #5 0x41ea6d in _start (/zhengjie/cmdline-fuzz/programs/mp4box/builds/build10/bin/gcc/MP4Box+0x41ea6d)

0x611000001009 is located 0 bytes to the right of 201-byte region [0x611000000f40,0x611000001009)
allocated by thread T0 here:
    #0 0x499ccd in malloc (/zhengjie/cmdline-fuzz/programs/mp4box/builds/build10/bin/gcc/MP4Box+0x499ccd)
    #1 0x841fd9 in Media_GetSample/programs/mp4box/builds/build10/src/isomedia/media.c:625:29
    #2 0x7d9fd0 in gf_isom_get_sample_ex/programs/mp4box/builds/build10/src/isomedia/isom_read.c:1905:6
    #3 0x4f40a0 in dump_isom_nal_ex/programs/mp4box/builds/build10/applications/mp4box/filedump.c:1234:24
    #4 0x4f8170 in dump_isom_xml/programs/mp4box/builds/build10/applications/mp4box/filedump.c:2001:9
    #5 0x4e0da8 in mp4boxMain/programs/mp4box/builds/build10/applications/mp4box/main.c:6171:7
    #6 0x7fa1487680b2 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x270b2)

SUMMARY: AddressSanitizer: heap-buffer-overflow/programs/mp4box/builds/build10/applications/mp4box/filedump.c:1007:20 in read_nal_size_hdr
Shadow bytes around the buggy address:
  0x0c227fff81b0: 00 00 00 00 00 00 00 fa fa fa fa fa fa fa fa fa
  0x0c227fff81c0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x0c227fff81d0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 fa fa
  0x0c227fff81e0: fa fa fa fa fa fa fa fa 00 00 00 00 00 00 00 00
  0x0c227fff81f0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
=>0x0c227fff8200: 00[01]fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0c227fff8210: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0c227fff8220: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0c227fff8230: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0c227fff8240: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0c227fff8250: 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
==10522==ABORTING
```
--- end body ---
