heap-buffer-overflow of Ap4DataBuffer.cpp in function ReallocateBuffer

Hi
I found an crash erro.

System info：
Ubuntu 20.04 : clang 10.0.0 , gcc 9.3.0

Bento4 version 1.6.0.0

commit:0c7705733de80172712e487dd6fdd28387fd7184

[poc.zip](https://github.com/axiomatic-systems/Bento4/files/6469895/poc4.zip)

------------------------------------------
Verification steps：
1.Get the source code of Bento4
2.Compile the Bento4

```bash
$ cd Bento4
$ mkdir check_build && cd check_build
$ cmake ../ -DCMAKE_C_COMPILER=clang  -DCMAKE_CXX_COMPILER=clang++ -DCMAKE_C_FLAGS="-fsanitize=address" -DCMAKE_CXX_FLAGS="-fsanitize=address"
$ make -j 32
```

3.run hevcinfo
```bash
$ ./hevcinfo poc  
```

asan info
```bash
=================================================================
==4072928==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x602000000011 at pc 0x0000004c77c7 bp 0x7ffece40e830 sp 0x7ffece40e828
READ of size 1 at 0x602000000011 thread T0
    #0 0x4c77c6 in main /home/hh/Downloads/Bento4/Source/C++/Apps/HevcInfo/HevcInfo.cpp:127:46
    #1 0x7f6619c790b2 in __libc_start_main /build/glibc-eX1tMB/glibc-2.31/csu/../csu/libc-start.c:308:16
    #2 0x41c3dd in _start (/home/hh/Downloads/Bento4/target/hevcinfo+0x41c3dd)

0x602000000011 is located 0 bytes to the right of 1-byte region [0x602000000010,0x602000000011)
allocated by thread T0 here:
    #0 0x4c439d in operator new[](unsigned long) (/home/hh/Downloads/Bento4/target/hevcinfo+0x4c439d)
    #1 0x4d385f in AP4_DataBuffer::ReallocateBuffer(unsigned int) /home/hh/Downloads/Bento4/Source/C++/Core/Ap4DataBuffer.cpp:210:28
    #2 0x4d385f in AP4_DataBuffer::SetDataSize(unsigned int) /home/hh/Downloads/Bento4/Source/C++/Core/Ap4DataBuffer.cpp:151:33

SUMMARY: AddressSanitizer: heap-buffer-overflow /home/hh/Downloads/Bento4/Source/C++/Apps/HevcInfo/HevcInfo.cpp:127:46 in main
Shadow bytes around the buggy address:
  0x0c047fff7fb0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x0c047fff7fc0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x0c047fff7fd0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x0c047fff7fe0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x0c047fff7ff0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
=>0x0c047fff8000: fa fa[01]fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0c047fff8010: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0c047fff8020: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0c047fff8030: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0c047fff8040: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0c047fff8050: 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
==4072928==ABORTING
```
heap-buffer-overflow of Ap4DataBuffer.cpp in function ReallocateBuffer
This is a GitHub Issue
repo:Bento4
owner:axiomatic-systems
Title : heap-buffer-overflow of Ap4DataBuffer.cpp in function ReallocateBuffer
Issue date:

--- start body ---
heap-buffer-overflow of Ap4DataBuffer.cpp in function ReallocateBuffer

Hi
I found an crash erro.

System info：
Ubuntu 20.04 : clang 10.0.0 , gcc 9.3.0

Bento4 version 1.6.0.0

commit:0c7705733de80172712e487dd6fdd28387fd7184

[poc.zip](https://github.com/axiomatic-systems/Bento4/files/6469895/poc4.zip)

------------------------------------------
Verification steps：
1.Get the source code of Bento4
2.Compile the Bento4

```bash
$ cd Bento4
$ mkdir check_build && cd check_build
$ cmake ../ -DCMAKE_C_COMPILER=clang  -DCMAKE_CXX_COMPILER=clang++ -DCMAKE_C_FLAGS="-fsanitize=address" -DCMAKE_CXX_FLAGS="-fsanitize=address"
$ make -j 32
```

3.run hevcinfo
```bash
$ ./hevcinfo poc  
```

asan info
```bash
=================================================================
==4072928==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x602000000011 at pc 0x0000004c77c7 bp 0x7ffece40e830 sp 0x7ffece40e828
READ of size 1 at 0x602000000011 thread T0
    #0 0x4c77c6 in main /home/hh/Downloads/Bento4/Source/C++/Apps/HevcInfo/HevcInfo.cpp:127:46
    #1 0x7f6619c790b2 in __libc_start_main /build/glibc-eX1tMB/glibc-2.31/csu/../csu/libc-start.c:308:16
    #2 0x41c3dd in _start (/home/hh/Downloads/Bento4/target/hevcinfo+0x41c3dd)

0x602000000011 is located 0 bytes to the right of 1-byte region [0x602000000010,0x602000000011)
allocated by thread T0 here:
    #0 0x4c439d in operator new[](unsigned long) (/home/hh/Downloads/Bento4/target/hevcinfo+0x4c439d)
    #1 0x4d385f in AP4_DataBuffer::ReallocateBuffer(unsigned int) /home/hh/Downloads/Bento4/Source/C++/Core/Ap4DataBuffer.cpp:210:28
    #2 0x4d385f in AP4_DataBuffer::SetDataSize(unsigned int) /home/hh/Downloads/Bento4/Source/C++/Core/Ap4DataBuffer.cpp:151:33

SUMMARY: AddressSanitizer: heap-buffer-overflow /home/hh/Downloads/Bento4/Source/C++/Apps/HevcInfo/HevcInfo.cpp:127:46 in main
Shadow bytes around the buggy address:
  0x0c047fff7fb0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x0c047fff7fc0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x0c047fff7fd0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x0c047fff7fe0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x0c047fff7ff0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
=>0x0c047fff8000: fa fa[01]fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0c047fff8010: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0c047fff8020: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0c047fff8030: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0c047fff8040: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0c047fff8050: 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
==4072928==ABORTING
```
--- end body ---

A heap buffer overflow vulnerability in the ReallocateBuffer function of Ap4DataBuffer.cpp in Bento4 version 1.6.0.0 can lead to crashes or potential exploitation. The issue arises when the function attempts to reallocate memory without proper bounds checking, allowing for out-of-bounds memory access.