Thanks for reporting your issue. Please make sure these boxes are checked before submitting your issue - thank you!

- [x] I looked for a similar issue and couldn't find any.
- [x] I tried with the latest version of GPAC. Installers available at http://gpac.io/downloads/gpac-nightly-builds/
- [x] I give enough information for contributors to reproduce my issue (meaningful title, github labels, platform and compiler, command-line ...). I can share files anonymously with this dropbox: https://www.mediafire.com/filedrop/filedrop_hosted.php?drop=eec9e058a9486fe4e99c33021481d9e1826ca9dbc242a6cfaab0fe95da5e5d95

Hi, there.

There is an invalid memory write in gf_sk_receive_internal, os_net.c:2305 with commit  6c7e0564303fa1690a744ad51a6b473564ea6d1a, which could lead to arbitrary memory access and code execution. 

Here is my environment, compiler info and gpac version:
~~~~
Distributor ID:	Ubuntu
Description:	20.04.6 LTS
Compiler: Clang 14.0.1

MP4Box - GPAC version 2.3-DEV-rev543-g6c7e05643-master
(c) 2000-2023 Telecom Paris distributed under LGPL v2.1+ - http://gpac.io

Please cite our work in your research:
	GPAC Filters: https://doi.org/10.1145/3339825.3394929
	GPAC: https://doi.org/10.1145/1291233.1291452

GPAC Configuration: --disable-shared
Features: GPAC_CONFIG_LINUX GPAC_64_BITS GPAC_HAS_IPV6 GPAC_HAS_SSL GPAC_HAS_SOCK_UN GPAC_MINIMAL_ODF GPAC_HAS_QJS GPAC_HAS_JPEG GPAC_HAS_PNG GPAC_HAS_JP2 GPAC_HAS_VORBIS GPAC_HAS_LINUX_DVB  GPAC_DISABLE_3D 
~~~~

To reproduce, run
~~~~
./MP4Box -info  -out /dev/null  poc
~~~~

POC:

[poc.zip](https://github.com/gpac/gpac/files/12818174/mp4box-overwrite-receive_internal2305.zip)
(unzip first)


Here is the trace reported by asan:
~~~~
==1464125==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x62100002e1f0 at pc 0x7f55e33beb6d bp 0x7ffe175e4f00 sp 0x7ffe175e46a8
 WRITE of size 4280 at 0x62100002e1f0 thread T0
     #0 0x7f55e33beb6c in __interceptor_recv ../../../../src/libsanitizer/sanitizer_common/sanitizer_common_interceptors.inc:6273
     #1 0x7f55dbef56da in gf_sk_receive_internal  /benchmark/gpac/src/utils/os_net.c:2305
     #2 0x7f55dbef5a5a in gf_sk_receive  /benchmark/gpac/src/utils/os_net.c:2350
     #3 0x7f55dbf3204c in gf_dm_read_data  /benchmark/gpac/src/utils/downloader.c:3122
     #4 0x7f55dbf5af43 in wait_for_header_and_parse  /benchmark/gpac/src/utils/downloader.c:5880
     #5 0x7f55dbf614e5 in http_do_requests  /benchmark/gpac/src/utils/downloader.c:6347
     #6 0x7f55dbf45921 in gf_dm_sess_fetch_data  /benchmark/gpac/src/utils/downloader.c:4520
     #7 0x7f55ddb5efb4 in httpin_process  /benchmark/gpac/src/filters/in_http.c:466
     #8 0x7f55dd75ce3f in gf_filter_process_task  /benchmark/gpac/src/filter_core/filter.c:2971
     #9 0x7f55dd70446b in gf_fs_thread_proc  /benchmark/gpac/src/filter_core/filter_session.c:2070
     #10 0x7f55dd707b72 in gf_fs_run  /benchmark/gpac/src/filter_core/filter_session.c:2370
     #11 0x7f55dccebae4 in gf_media_import  /benchmark/gpac/src/media_tools/media_import.c:1239
     #12 0x563e084dfc7f in convert_file_info  /benchmark/gpac/applications/mp4box/fileimport.c:130
     #13 0x563e0849669b in mp4box_main  /benchmark/gpac/applications/mp4box/mp4box.c:6380
     #14 0x563e084993c4 in main  /benchmark/gpac/applications/mp4box/mp4box.c:6939
     #15 0x7f55d7e09082 in __libc_start_main ../csu/libc-start.c:308
     #16 0x563e08456d4d in _start ( /benchmark/gpac/build-t/bin/gcc/MP4Box+0x107d4d)
 
 0x62100002e1f0 is located 0 bytes to the right of 4336-byte region [0x62100002d100,0x62100002e1f0)
 allocated by thread T0 here:
     #0 0x7f55e3472c3e in __interceptor_realloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cc:163
     #1 0x7f55dbe4739c in gf_realloc  /benchmark/gpac/src/utils/alloc.c:160
     #2 0x7f55dbf561a9 in wait_for_header_and_parse  /benchmark/gpac/src/utils/downloader.c:5519
     #3 0x7f55dbf614e5 in http_do_requests  /benchmark/gpac/src/utils/downloader.c:6347
     #4 0x7f55dbf45921 in gf_dm_sess_fetch_data  /benchmark/gpac/src/utils/downloader.c:4520
     #5 0x7f55ddb5efb4 in httpin_process  /benchmark/gpac/src/filters/in_http.c:466
     #6 0x7f55dd75ce3f in gf_filter_process_task  /benchmark/gpac/src/filter_core/filter.c:2971
     #7 0x7f55dd70446b in gf_fs_thread_proc  /benchmark/gpac/src/filter_core/filter_session.c:2070
     #8 0x7f55dd707b72 in gf_fs_run  /benchmark/gpac/src/filter_core/filter_session.c:2370
     #9 0x7f55dccebae4 in gf_media_import  /benchmark/gpac/src/media_tools/media_import.c:1239
     #10 0x563e084dfc7f in convert_file_info  /benchmark/gpac/applications/mp4box/fileimport.c:130
     #11 0x563e0849669b in mp4box_main  /benchmark/gpac/applications/mp4box/mp4box.c:6380
     #12 0x563e084993c4 in main  /benchmark/gpac/applications/mp4box/mp4box.c:6939
     #13 0x7f55d7e09082 in __libc_start_main ../csu/libc-start.c:308
 
 SUMMARY: AddressSanitizer: heap-buffer-overflow ../../../../src/libsanitizer/sanitizer_common/sanitizer_common_interceptors.inc:6273 in __interceptor_recv
 Shadow bytes around the buggy address:
   0x0c427fffdbe0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
   0x0c427fffdbf0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
   0x0c427fffdc00: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
   0x0c427fffdc10: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
   0x0c427fffdc20: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 =>0x0c427fffdc30: 00 00 00 00 00 00 00 00 00 00 00 00 00 00[fa]fa
   0x0c427fffdc40: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
   0x0c427fffdc50: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
   0x0c427fffdc60: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
   0x0c427fffdc70: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
   0x0c427fffdc80: 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
 ==1464125==ABORTING
~~~~



heap buffer overflow in gf_sk_receive_internal, os_net.c:2305
This is a GitHub Issue
repo:gpac
owner:gpac
Title : heap buffer overflow in gf_sk_receive_internal, os_net.c:2305
Issue date:

--- start body ---
Thanks for reporting your issue. Please make sure these boxes are checked before submitting your issue - thank you!

- [x] I looked for a similar issue and couldn't find any.
- [x] I tried with the latest version of GPAC. Installers available at http://gpac.io/downloads/gpac-nightly-builds/
- [x] I give enough information for contributors to reproduce my issue (meaningful title, github labels, platform and compiler, command-line ...). I can share files anonymously with this dropbox: https://www.mediafire.com/filedrop/filedrop_hosted.php?drop=eec9e058a9486fe4e99c33021481d9e1826ca9dbc242a6cfaab0fe95da5e5d95

Hi, there.

There is an invalid memory write in gf_sk_receive_internal, os_net.c:2305 with commit  6c7e0564303fa1690a744ad51a6b473564ea6d1a, which could lead to arbitrary memory access and code execution. 

Here is my environment, compiler info and gpac version:
~~~~
Distributor ID:	Ubuntu
Description:	20.04.6 LTS
Compiler: Clang 14.0.1

MP4Box - GPAC version 2.3-DEV-rev543-g6c7e05643-master
(c) 2000-2023 Telecom Paris distributed under LGPL v2.1+ - http://gpac.io

Please cite our work in your research:
	GPAC Filters: https://doi.org/10.1145/3339825.3394929
	GPAC: https://doi.org/10.1145/1291233.1291452

GPAC Configuration: --disable-shared
Features: GPAC_CONFIG_LINUX GPAC_64_BITS GPAC_HAS_IPV6 GPAC_HAS_SSL GPAC_HAS_SOCK_UN GPAC_MINIMAL_ODF GPAC_HAS_QJS GPAC_HAS_JPEG GPAC_HAS_PNG GPAC_HAS_JP2 GPAC_HAS_VORBIS GPAC_HAS_LINUX_DVB  GPAC_DISABLE_3D 
~~~~

To reproduce, run
~~~~
./MP4Box -info  -out /dev/null  poc
~~~~

POC:

[poc.zip](https://github.com/gpac/gpac/files/12818174/mp4box-overwrite-receive_internal2305.zip)
(unzip first)


Here is the trace reported by asan:
~~~~
==1464125==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x62100002e1f0 at pc 0x7f55e33beb6d bp 0x7ffe175e4f00 sp 0x7ffe175e46a8
 WRITE of size 4280 at 0x62100002e1f0 thread T0
     #0 0x7f55e33beb6c in __interceptor_recv ../../../../src/libsanitizer/sanitizer_common/sanitizer_common_interceptors.inc:6273
     #1 0x7f55dbef56da in gf_sk_receive_internal  /benchmark/gpac/src/utils/os_net.c:2305
     #2 0x7f55dbef5a5a in gf_sk_receive  /benchmark/gpac/src/utils/os_net.c:2350
     #3 0x7f55dbf3204c in gf_dm_read_data  /benchmark/gpac/src/utils/downloader.c:3122
     #4 0x7f55dbf5af43 in wait_for_header_and_parse  /benchmark/gpac/src/utils/downloader.c:5880
     #5 0x7f55dbf614e5 in http_do_requests  /benchmark/gpac/src/utils/downloader.c:6347
     #6 0x7f55dbf45921 in gf_dm_sess_fetch_data  /benchmark/gpac/src/utils/downloader.c:4520
     #7 0x7f55ddb5efb4 in httpin_process  /benchmark/gpac/src/filters/in_http.c:466
     #8 0x7f55dd75ce3f in gf_filter_process_task  /benchmark/gpac/src/filter_core/filter.c:2971
     #9 0x7f55dd70446b in gf_fs_thread_proc  /benchmark/gpac/src/filter_core/filter_session.c:2070
     #10 0x7f55dd707b72 in gf_fs_run  /benchmark/gpac/src/filter_core/filter_session.c:2370
     #11 0x7f55dccebae4 in gf_media_import  /benchmark/gpac/src/media_tools/media_import.c:1239
     #12 0x563e084dfc7f in convert_file_info  /benchmark/gpac/applications/mp4box/fileimport.c:130
     #13 0x563e0849669b in mp4box_main  /benchmark/gpac/applications/mp4box/mp4box.c:6380
     #14 0x563e084993c4 in main  /benchmark/gpac/applications/mp4box/mp4box.c:6939
     #15 0x7f55d7e09082 in __libc_start_main ../csu/libc-start.c:308
     #16 0x563e08456d4d in _start ( /benchmark/gpac/build-t/bin/gcc/MP4Box+0x107d4d)
 
 0x62100002e1f0 is located 0 bytes to the right of 4336-byte region [0x62100002d100,0x62100002e1f0)
 allocated by thread T0 here:
     #0 0x7f55e3472c3e in __interceptor_realloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cc:163
     #1 0x7f55dbe4739c in gf_realloc  /benchmark/gpac/src/utils/alloc.c:160
     #2 0x7f55dbf561a9 in wait_for_header_and_parse  /benchmark/gpac/src/utils/downloader.c:5519
     #3 0x7f55dbf614e5 in http_do_requests  /benchmark/gpac/src/utils/downloader.c:6347
     #4 0x7f55dbf45921 in gf_dm_sess_fetch_data  /benchmark/gpac/src/utils/downloader.c:4520
     #5 0x7f55ddb5efb4 in httpin_process  /benchmark/gpac/src/filters/in_http.c:466
     #6 0x7f55dd75ce3f in gf_filter_process_task  /benchmark/gpac/src/filter_core/filter.c:2971
     #7 0x7f55dd70446b in gf_fs_thread_proc  /benchmark/gpac/src/filter_core/filter_session.c:2070
     #8 0x7f55dd707b72 in gf_fs_run  /benchmark/gpac/src/filter_core/filter_session.c:2370
     #9 0x7f55dccebae4 in gf_media_import  /benchmark/gpac/src/media_tools/media_import.c:1239
     #10 0x563e084dfc7f in convert_file_info  /benchmark/gpac/applications/mp4box/fileimport.c:130
     #11 0x563e0849669b in mp4box_main  /benchmark/gpac/applications/mp4box/mp4box.c:6380
     #12 0x563e084993c4 in main  /benchmark/gpac/applications/mp4box/mp4box.c:6939
     #13 0x7f55d7e09082 in __libc_start_main ../csu/libc-start.c:308
 
 SUMMARY: AddressSanitizer: heap-buffer-overflow ../../../../src/libsanitizer/sanitizer_common/sanitizer_common_interceptors.inc:6273 in __interceptor_recv
 Shadow bytes around the buggy address:
   0x0c427fffdbe0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
   0x0c427fffdbf0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
   0x0c427fffdc00: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
   0x0c427fffdc10: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
   0x0c427fffdc20: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 =>0x0c427fffdc30: 00 00 00 00 00 00 00 00 00 00 00 00 00 00[fa]fa
   0x0c427fffdc40: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
   0x0c427fffdc50: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
   0x0c427fffdc60: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
   0x0c427fffdc70: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
   0x0c427fffdc80: 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
 ==1464125==ABORTING
~~~~



--- end body ---
