mirror of
https://gitee.com/xia-chu/ZLMediaKit.git
synced 2026-05-06 10:57:50 +08:00
修复http文件下载指定目录时mmap导致崩溃的bug (#4213)
Some checks are pending
Android / build (push) Waiting to run
CodeQL / Analyze (cpp) (push) Waiting to run
CodeQL / Analyze (javascript) (push) Waiting to run
Docker / build (push) Waiting to run
Linux / build (push) Waiting to run
macOS / build (push) Waiting to run
Windows / build (push) Waiting to run
Some checks are pending
Android / build (push) Waiting to run
CodeQL / Analyze (cpp) (push) Waiting to run
CodeQL / Analyze (javascript) (push) Waiting to run
Docker / build (push) Waiting to run
Linux / build (push) Waiting to run
macOS / build (push) Waiting to run
Windows / build (push) Waiting to run
在`HttpBody.cpp`中,`getSharedMmap`函数直接尝试对所有路径进行mmap操作,没有进行文件类型检查
This commit is contained in:
parent
026e74d624
commit
56fe66da7c
@ -194,6 +194,13 @@ static std::shared_ptr<char> getSharedMmap(const string &file_path, int64_t &fil
|
||||
}
|
||||
|
||||
HttpFileBody::HttpFileBody(const string &file_path, bool use_mmap) {
|
||||
|
||||
// 判断是否为目录,避免对目录进行mmap操作,导致程序崩溃。
|
||||
if (File::is_dir(file_path)) {
|
||||
_read_to = -1;
|
||||
return;
|
||||
}
|
||||
|
||||
if (use_mmap ) {
|
||||
_map_addr = getSharedMmap(file_path, _read_to);
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user