## 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-rev1705-gc3ed3094a-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/8000892/poc.zip)


## Crash output

```
==5605==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x6030000012b5 at pc 0x000000cdf2da bp 0x7ffebb3cfc90 sp 0x7ffebb3cfc88
READ of size 1 at 0x6030000012b5 thread T0
    #0 0xcdf2d9 in inspect_get_nal_size /programs/mp4box/builds/build8/src/filters/inspect.c:177:20
    #1 0xcdf2d9 in gf_inspect_dump_nalu_internal /programs/mp4box/builds/build8/src/filters/inspect.c:1182:15
    #2 0xcd8b3f in gf_inspect_dump_nalu /programs/mp4box/builds/build8/src/filters/inspect.c:1222:2
    #3 0x4f4863 in dump_isom_nal_ex /programs/mp4box/builds/build8/applications/mp4box/filedump.c:1288:5
    #4 0x4f8170 in dump_isom_xml /programs/mp4box/builds/build8/applications/mp4box/filedump.c:2001:9
    #5 0x4e0da8 in mp4boxMain /programs/mp4box/builds/build8/applications/mp4box/main.c:6171:7
    #6 0x7fbf444fb0b2 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x270b2)
    #7 0x41ea6d in _start (/programs/mp4box/builds/build8/bin/gcc/MP4Box+0x41ea6d)

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

SUMMARY: AddressSanitizer: heap-buffer-overflow /programs/mp4box/builds/build8/src/filters/inspect.c:177:20 in inspect_get_nal_size
Shadow bytes around the buggy address:
  0x0c067fff8200: fd fd fd fa fa fa fd fd fd fa fa fa 00 00 04 fa
  0x0c067fff8210: fa fa 00 00 04 fa fa fa fd fd fd fa fa fa fd fd
  0x0c067fff8220: fd fa fa fa fd fd fd fa fa fa fd fd fd fa fa fa
  0x0c067fff8230: fd fd fd fa fa fa fd fd fd fa fa fa fd fd fd fa
  0x0c067fff8240: fa fa fd fd fd fd fa fa fd fd fd fa fa fa fd fd
=>0x0c067fff8250: fd fa fa fa 00 00[05]fa fa fa fa fa fa fa fa fa
  0x0c067fff8260: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0c067fff8270: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0c067fff8280: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0c067fff8290: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0c067fff82a0: 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
==5605==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-rev1705-gc3ed3094a-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/8000892/poc.zip)


## Crash output

```
==5605==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x6030000012b5 at pc 0x000000cdf2da bp 0x7ffebb3cfc90 sp 0x7ffebb3cfc88
READ of size 1 at 0x6030000012b5 thread T0
    #0 0xcdf2d9 in inspect_get_nal_size /programs/mp4box/builds/build8/src/filters/inspect.c:177:20
    #1 0xcdf2d9 in gf_inspect_dump_nalu_internal /programs/mp4box/builds/build8/src/filters/inspect.c:1182:15
    #2 0xcd8b3f in gf_inspect_dump_nalu /programs/mp4box/builds/build8/src/filters/inspect.c:1222:2
    #3 0x4f4863 in dump_isom_nal_ex /programs/mp4box/builds/build8/applications/mp4box/filedump.c:1288:5
    #4 0x4f8170 in dump_isom_xml /programs/mp4box/builds/build8/applications/mp4box/filedump.c:2001:9
    #5 0x4e0da8 in mp4boxMain /programs/mp4box/builds/build8/applications/mp4box/main.c:6171:7
    #6 0x7fbf444fb0b2 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x270b2)
    #7 0x41ea6d in _start (/programs/mp4box/builds/build8/bin/gcc/MP4Box+0x41ea6d)

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

SUMMARY: AddressSanitizer: heap-buffer-overflow /programs/mp4box/builds/build8/src/filters/inspect.c:177:20 in inspect_get_nal_size
Shadow bytes around the buggy address:
  0x0c067fff8200: fd fd fd fa fa fa fd fd fd fa fa fa 00 00 04 fa
  0x0c067fff8210: fa fa 00 00 04 fa fa fa fd fd fd fa fa fa fd fd
  0x0c067fff8220: fd fa fa fa fd fd fd fa fa fa fd fd fd fa fa fa
  0x0c067fff8230: fd fd fd fa fa fa fd fd fd fa fa fa fd fd fd fa
  0x0c067fff8240: fa fa fd fd fd fd fa fa fd fd fd fa fa fa fd fd
=>0x0c067fff8250: fd fa fa fa 00 00[05]fa fa fa fa fa fa fa fa fa
  0x0c067fff8260: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0c067fff8270: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0c067fff8280: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0c067fff8290: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0c067fff82a0: 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
==5605==ABORTING
```
--- end body ---
