mirror of
https://github.com/ZLMediaKit/ZLMediaKit.git
synced 2026-07-29 21:38:22 +08:00
修复http文件下载指定目录时mmap导致崩溃的bug (#4213)
在`HttpBody.cpp`中,`getSharedMmap`函数直接尝试对所有路径进行mmap操作,没有进行文件类型检查
This commit is contained in:
@@ -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) {
|
HttpFileBody::HttpFileBody(const string &file_path, bool use_mmap) {
|
||||||
|
|
||||||
|
// 判断是否为目录,避免对目录进行mmap操作,导致程序崩溃。
|
||||||
|
if (File::is_dir(file_path)) {
|
||||||
|
_read_to = -1;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (use_mmap ) {
|
if (use_mmap ) {
|
||||||
_map_addr = getSharedMmap(file_path, _read_to);
|
_map_addr = getSharedMmap(file_path, _read_to);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user