## 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-rev1678-g92faba3ed-master
```

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

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

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


## Crash output

```
==542==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x61300000168d at pc 0x000001517364 bp 0x7fffd21f5330 sp 0x7fffd21f5328
READ of size 1 at 0x61300000168d thread T0
    #0 0x1517363 in gp_rtp_builder_do_mpeg12_video /programs/mp4box/builds/build4/src/ietf/rtp_pck_mpeg12.c:160:8
    #1 0xbab276 in gf_hinter_track_process /programs/mp4box/builds/build4/src/media_tools/isom_hinter.c:830:8
    #2 0x4de4cd in HintFile /programs/mp4box/builds/build4/applications/mp4box/main.c:3614:7
    #3 0x4ebbc7 in mp4boxMain /programs/mp4box/builds/build4/applications/mp4box/main.c:6475:7
    #4 0x7ff3f3d150b2 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x270b2)
    #5 0x41ea6d in _start (/programs/mp4box/builds/build4/bin/gcc/MP4Box+0x41ea6d)

0x61300000168d is located 0 bytes to the right of 333-byte region [0x613000001540,0x61300000168d)
allocated by thread T0 here:
    #0 0x499ccd in malloc (/programs/mp4box/builds/build4/bin/gcc/MP4Box+0x499ccd)
    #1 0x9a42bd in Media_GetSample /programs/mp4box/builds/build4/src/isomedia/media.c:625:29
    #2 0x91043f in gf_isom_get_sample_ex /programs/mp4box/builds/build4/src/isomedia/isom_read.c:1905:6
    #3 0xbaa54f in gf_hinter_track_process /programs/mp4box/builds/build4/src/media_tools/isom_hinter.c:746:10
    #4 0x4de4cd in HintFile /programs/mp4box/builds/build4/applications/mp4box/main.c:3614:7
    #5 0x4ebbc7 in mp4boxMain /programs/mp4box/builds/build4/applications/mp4box/main.c:6475:7
    #6 0x7ff3f3d150b2 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x270b2)

SUMMARY: AddressSanitizer: heap-buffer-overflow /programs/mp4box/builds/build4/src/ietf/rtp_pck_mpeg12.c:160:8 in gp_rtp_builder_do_mpeg12_video
Shadow bytes around the buggy address:
  0x0c267fff8280: fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd
  0x0c267fff8290: fd fd fd fd fd fd fd fd fd fd fa fa fa fa fa fa
  0x0c267fff82a0: fa fa fa fa fa fa fa fa 00 00 00 00 00 00 00 00
  0x0c267fff82b0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x0c267fff82c0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
=>0x0c267fff82d0: 00[05]fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0c267fff82e0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0c267fff82f0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0c267fff8300: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0c267fff8310: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0c267fff8320: 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
==542==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-rev1678-g92faba3ed-master
```

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

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

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


## Crash output

```
==542==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x61300000168d at pc 0x000001517364 bp 0x7fffd21f5330 sp 0x7fffd21f5328
READ of size 1 at 0x61300000168d thread T0
    #0 0x1517363 in gp_rtp_builder_do_mpeg12_video /programs/mp4box/builds/build4/src/ietf/rtp_pck_mpeg12.c:160:8
    #1 0xbab276 in gf_hinter_track_process /programs/mp4box/builds/build4/src/media_tools/isom_hinter.c:830:8
    #2 0x4de4cd in HintFile /programs/mp4box/builds/build4/applications/mp4box/main.c:3614:7
    #3 0x4ebbc7 in mp4boxMain /programs/mp4box/builds/build4/applications/mp4box/main.c:6475:7
    #4 0x7ff3f3d150b2 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x270b2)
    #5 0x41ea6d in _start (/programs/mp4box/builds/build4/bin/gcc/MP4Box+0x41ea6d)

0x61300000168d is located 0 bytes to the right of 333-byte region [0x613000001540,0x61300000168d)
allocated by thread T0 here:
    #0 0x499ccd in malloc (/programs/mp4box/builds/build4/bin/gcc/MP4Box+0x499ccd)
    #1 0x9a42bd in Media_GetSample /programs/mp4box/builds/build4/src/isomedia/media.c:625:29
    #2 0x91043f in gf_isom_get_sample_ex /programs/mp4box/builds/build4/src/isomedia/isom_read.c:1905:6
    #3 0xbaa54f in gf_hinter_track_process /programs/mp4box/builds/build4/src/media_tools/isom_hinter.c:746:10
    #4 0x4de4cd in HintFile /programs/mp4box/builds/build4/applications/mp4box/main.c:3614:7
    #5 0x4ebbc7 in mp4boxMain /programs/mp4box/builds/build4/applications/mp4box/main.c:6475:7
    #6 0x7ff3f3d150b2 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x270b2)

SUMMARY: AddressSanitizer: heap-buffer-overflow /programs/mp4box/builds/build4/src/ietf/rtp_pck_mpeg12.c:160:8 in gp_rtp_builder_do_mpeg12_video
Shadow bytes around the buggy address:
  0x0c267fff8280: fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd
  0x0c267fff8290: fd fd fd fd fd fd fd fd fd fd fa fa fa fa fa fa
  0x0c267fff82a0: fa fa fa fa fa fa fa fa 00 00 00 00 00 00 00 00
  0x0c267fff82b0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x0c267fff82c0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
=>0x0c267fff82d0: 00[05]fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0c267fff82e0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0c267fff82f0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0c267fff8300: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0c267fff8310: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0c267fff8320: 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
==542==ABORTING
```
--- end body ---

A heap-buffer-overflow vulnerability in GPAC version 1.1.0-DEV can be exploited when processing specially crafted MP4 files using the MP4Box tool. This vulnerability can lead to a crash or potentially allow for arbitrary code execution, depending on the context of the overflow.