Crashes when the number of properties is less than what the header defines
还没有人认领这个 Issue。
评估
调研方向
Start at the element-property loop that calls parseNext and inspect tokenSplit and parseNext together. Reproduce the supplied PLY example with fewer values than declared, then verify that the chosen bounds-checking behavior prevents an out-of-bounds access and handles the malformed row safely.
由索引模型根据 Issue 内容生成。
描述
Properties are parsed with a loop that is repeated elem.properties.size() times, which is the number of properties the header says this element should have.
vector<string> tokens = tokenSplit(line);
size_t iTok = 0;
for (size_t iP = 0; iP < elem.properties.size(); iP++) {
elem.properties[iP]->parseNext(tokens, iTok);
}
However if this element has less properties than the header defines, tokenSplit(line) returns a number of tokens less than elem.properties.size().
Then when we call parseNext, tokens[curEntry] is an out-of-bounds access and we crash when trying to create an istringstream from whatever garbage we read.
virtual void parseNext(const std::vector<std::string>& tokens, size_t& currEntry) override {
data.emplace_back();
std::istringstream iss(tokens[currEntry]);
typename SerializeType<T>::type tmp; // usually the same type as T
iss >> tmp;
data.back() = tmp;
currEntry++;
};
Here is an example file that will cause a crash:
ply
format ascii 1.0
element vertex 1
property float x
property float y
property char z
comment There are 3 properties but we provide only 2!
end_header
3 4
Possible fixes:
- Verify that the number of tokens matches the expected number of properties
- In
parseNext, ensure thatcurrEntryis withintokens.size() - In
parseNext, usetokens.at(currEntry)
- 主要语言
- C++
- 星标
- 406
- 派生
- 74
- PR 合并指标
- 30 天内没有已合并 PR
贡献指南
这个仓库没有索引到贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
nmwsharp/happly 的其他 Issue
-
难度 2/5 1-3 小时 新手友好度 76/100
-
难度 3/5 1-2 天 新手友好度 56/100
-
难度 3/5 1-2 天 新手友好度 48/100
-
难度 2/5 1-3 小时 新手友好度 45/100
-
难度 5/5 一周以上 新手友好度 20/100
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 75/100
-
good first issue
难度 2/5 1-3 小时 新手友好度 75/100
ros2/message_filters#338 ·
-
难度 2/5 1-3 小时 新手友好度 70/100
subsurface/subsurface#4984 ·
-
难度 2/5 1-3 小时 新手友好度 75/100
flutter-webrtc/flutter-webrtc#2206 ·
-
难度 2/5 1-3 小时 新手友好度 70/100
google-ai-edge/LiteRT-LM#3739 ·