mirror of
https://github.com/ZLMediaKit/ZLMediaKit.git
synced 2026-11-24 00:47:21 +08:00
### Motivation - Prevent a memory-amplification DoS in RTMP DATA/CMD handling where the compatibility helper decoded arbitrary leading AMF values (including large strict arrays) while searching for the first string. - Support the observed non-standard publisher case (two leading AMF0 numbers) while avoiding unbounded recursive decoding and attacker-controlled allocations. ### Description - Replace the unbounded `amfLoadLeadingString()` behavior that repeatedly `load<AMFValue>()` with a bounded compatibility rule that skips at most two AMF0 `Number` values and then requires a string (`amfLoadLeadingString` in `src/Rtmp/amf.cpp` and declaration in `src/Rtmp/amf.h`). - Add `friend` linkage for the helper in `AMFDecoder` and update header comments to document the tightened compatibility semantics. - Extend `tests/test_amf.cpp` with regression checks covering: zero/one/two leading numbers, rejection of complex leading values (e.g. strict array), excessive leading numbers, and AMF3 string handling. - No new source files added and existing file UTF-8 BOMs were preserved. ### Testing - Ran configuration and unit build: `cmake -S . -B build -DENABLE_TESTS=ON -DCMAKE_BUILD_TYPE=Debug` then `cmake --build build --target test_amf -j8` and the build completed successfully. - Executed the test binary via CTest: `ctest --test-dir build -R '^test_amf$' --output-on-failure` and `test_amf` passed (1/1 tests passed). - Ran `git diff --check` and ensured no trailing whitespace or check errors after changes. ------ [Codex Task](https://chatgpt.com/codex/cloud/tasks/task_e_6abb8adc6f5c8320a84e8b198e28f68b)
此目录下的所有.cpp文件将被编译成可执行程序(不包含此目录下的子目录). 子目录DeviceHK为海康IPC的适配程序,需要先下载海康的SDK才能编译, 由于操作麻烦,所以仅把源码放在这里仅供参考.
-
test_benchmark.cpp
rtsp/rtmp性能测试客户端
-
test_httpApi.cpp
http api 测试服务器
-
test_httpClient.cpp
http 测试客户端
-
test_player.cpp
rtsp/rtmp带视频渲染的客户端
-
test_pusher.cpp
先拉流再推流的测试客户端
-
test_pusherMp4.cpp
解复用mp4文件再推流的测试客户端
-
test_server.cpp
rtsp/rtmp/http等服务器
-
test_wsClient.cpp
websocket测试客户端
-
test_wsServer.cpp
websocket回显测试服务器