Crashes when the number of properties is less than what the header defines
まだ誰も着手していません。
評価
調査の方向性
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 にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- 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 1週間以上 初心者へのやさしさ 20/100
nmwsharp/happly の issue をすべて見る
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
google/libultrahdr#485 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
godotengine/godot#123776 ·
-
bug
難易度 1/5 1時間未満 初心者へのやさしさ 60/100
-
good first issue
難易度 1/5 1時間未満 初心者へのやさしさ 90/100
-
good first issue
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
ros2/common_interfaces#344 ·