View Issue Details

IDProjectCategoryView StatusLast Update
0000609fileGeneralpublic2025-01-08 06:45
ReporterYancyLii Assigned To 
PriorityurgentSeveritycrashReproducibilityalways
Status newResolutionopen 
OSubuntuOS Version22.04 
Product Version5.46 
Summary0000609: Out-of-memory Bug in libmagic's add_mlist Function
DescriptionWhen processing certain input through magic_load_buffers(), libmagic attempts to allocate approximately 32GB of memory (34,359,738,344 bytes) in the add_mlist function, leading to an out-of-memory crash. This indicates a potential integer overflow or input validation issue in buffer size calculations.
Steps To Reproduce1. Download the attachment tar.gz file and decompress it, then (sudo) execute shell script
2. ./Test_libmagic_2 oom-662137c8ddec9e0091b61b30ba985505aeab69cd
3. Observe the error message
Additional InformationThe crash occurs when:
1.Input data is passed to magic_load_buffers()
2.During processing in buffer_apprentice(), a call to add_mlist() is made
3.add_mlist() attempts to allocate 34,359,738,344 bytes using calloc
4.The allocation fails due to insufficient memory

Stack Trace:
0000008 0x55e691bbdbe2 in add_mlist .../libmagic/src/libmagic/build/src/../../src/apprentice.c:455:22
#9 0x55e691bbd4e0 in buffer_apprentice.../libmagic/src/libmagic/build/src/../../src/apprentice.c:720:8
0000010 0x55e691bbab1b in magic_load_buffers .../libmagic/src/libmagic/build/src/../../src/magic.c:334:9
Tagslibmagic

Activities

YancyLii

2025-01-08 06:45

reporter  

Test_libmagic_2.tar.gz (1,378 bytes)

Issue History

Date Modified Username Field Change
2025-01-08 06:45 YancyLii New Issue
2025-01-08 06:45 YancyLii Tag Attached: libmagic
2025-01-08 06:45 YancyLii File Added: Test_libmagic_2.tar.gz