fix: use bounded formatting for Vorbis metadata names#1250
Conversation
Automated security fix generated by OrbisAI Security
The Vorbis producer module uses sprintf() to format a metadata attribute name from a Vorbis file's comment tags into a fixed-size buffer (meta->name) without any bounds checking
ddennedy
left a comment
There was a problem hiding this comment.
Thank you for the report and contribution. The included test does not conform to this repository's choice of QTest for unit tests. See src/tests/test_mod_avformat/ for an example. The project also uses CMake; so a new test directory should be added to src/tests/CMakeLists.txt.
Replace Check-based test with QTest following MLT conventions: - Remove tests/test_invariant_producer_vorbis.c (Check framework) - Add src/tests/test_vorbis/test_vorbis.cpp (QTest framework) - Register test in src/tests/CMakeLists.txt under MOD_VORBIS The new test follows the pattern established in test_mod_avformat and integrates with MLT's existing QTest/CMake infrastructure. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
orbisai0security
left a comment
There was a problem hiding this comment.
Thanks for the review and for pointing me to the project's test conventions. I agree the current test should not introduce a different unit-test framework.
I've revised this PR to:
- Migrate the test to QTest framework, following the pattern in
src/tests/test_mod_avformat/ - Register the test in
src/tests/CMakeLists.txtunder theMOD_VORBISconditional - Update the PR description to accurately reflect that
meta->nameis dynamically allocated withmalloc(strlen(str) + 18) - Reframe this as defensive hardening rather than fixing a critical overflow
You're absolutely right that the original wording about "fixed-size buffer" was incorrect — the allocation is sized appropriately based on the input string length. The snprintf change is primarily about making this code path more robust against future changes and following secure coding best practices.
The test is now much simpler and follows MLT's conventions, focusing on integration testing through the public API rather than trying to simulate the vulnerability with synthetic buffers.
Summary
Replace sprintf() with snprintf() when constructing Vorbis metadata attribute names.
The destination buffer
meta->nameis dynamically allocated based on the input key length plus the fixed format overhead (strlen(str) + 18), so the current code is already sized correctly. However, using snprintf() is a defensive hardening improvement that:Changes
src/modules/vorbis/producer_vorbis.c- Replace sprintf with snprintfsrc/tests/test_vorbis/test_vorbis.cpp- Add QTest-based test following MLT conventionsVerification
Technical Details
Before:
After:
The format string overhead is 18 bytes:
This change makes the code more robust and follows defense-in-depth principles, even though the allocation is already appropriately sized.
Automated security fix by OrbisAI Security