XMLPrinter::Write() error and possible overflow.
まだ誰も着手していません。
評価
調査の方向性
The bug is in XMLPrinter::Write() in tinyxml2.cpp, where the buffer path casts size to int before calling _buffer.PushArr(). Read PushArr's signature and the surrounding buffer code to confirm the size type, then check how the sibling tests in xmltest.cpp exercise XMLPrinter. Done means the cast is removed or bounded safely, the size_t value is passed through correctly, and the existing test suite still passes; the maintainer's comments decide whether the fix belongs to this change.
索引モデルが issue の本文から書いたものです。
説明
A very recent download (this week) has
void XMLPrinter::Write( const char* data, size_t size )
{
if ( _fp ) {
fwrite ( data , sizeof(char), size, _fp);
}
else {
char* p = _buffer.PushArr( static_cast<int>(size) ) - 1; // back up over the null terminator.
memcpy( p, data, size );
p[size] = 0;
}
}
On many platforms, int is 32 bit but size_t is 64 bit. That static_cast(size) could result in an integer much smaller than the original size, meaning the later memcpy() has a good chance of trashing memory.
It may be that the tinyxml2 code would never call Write() with a size that large, but since Write is protected (not private), some class derived from XMLPrinter could do so.
It is not clear to me what the static_cast accomplishes, since PushArr expects a size_t argument.
- 主要言語
- C++
- スター
- 5.8k
- フォーク
- 2k
- PR マージ指標
- 30日以内にマージされた PR はありません
環境構築
このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
leethomason/tinyxml2 のほかの issue
-
XMLNode::InsertAfterChild dereferences NULL when addThis is already afterThis's next sibling対応中かも @zhouyunding が 17 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 88/100
leethomason/tinyxml2#1101 ·
-
CDATA output containing ]]> is not well-formed XML対応中かも @bconnnnn が 28 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
leethomason/tinyxml2#1097 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 62/100
leethomason/tinyxml2#923 · コメント 2 件 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 62/100
leethomason/tinyxml2#914 ·
-
New release requestオープン
難易度 2/5 1時間未満 初心者へのやさしさ 15/100
leethomason/tinyxml2#1087 · コメント 4 件 ·
leethomason/tinyxml2 の issue をすべて見る
似ている issue
-
documentation enhancement
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
メンテナーはふだん 1 日以内に返信
-
enhancement
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
QuantStack/git2cpp#203 ·
メンテナーはふだん 1 日以内に返信
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 65/100
BaptisteHudyma/Lamp-Da#588 ·
メンテナーはふだん 1 日以内に返信
-
bug macOS networking
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
メンテナーはふだん 2 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 85/100
docling-project/docling-parse#448 ·
メンテナーはふだん 5 日以内に返信