libgit2 / libgit2/libgit2sharp

Crash calling Repository.IsValid with corrupt .git/config

オープン
#1,851 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

主要言語
C#
スター
3.5k
フォーク
925
PR マージ指標
30日以内にマージされた PR はありません

説明

Reproduction steps

Add this to .git/config
[diff "mytool"] command = c:\path\to\my\tool\MyToolComparer.exe
This will cause the following effect for git

c:\my\git\repo> git status
fatal: bad config line 8 in file .git/config

Then call Repository.IsValid(@"c:\my\git\repo\.git") which is turn calls Proxy.git_repository_open_ext(path, RepositoryOpenFlags.NoSearch, null);

This fails because the return value from NativeMethods.git_repository_open_ext(out repo, path, flags, ceilingDirs) is not checked for error prior to freeing the out parameter repo (which is already free'd when there is an error condition in int git_repository_open_ext(git_repository **repo_ptr, const char *start_path, unsigned int flags, const char *ceiling_dirs))

Expected behavior

LibGit2Sharp.LibGit2SharpException

Actual behavior

Access violation (0xC0000005) in void git_repository_free(git_repository *repo) when dereferencing the null repo

Version of LibGit2Sharp (release number or SHA1)

0.27.0.34

Operating system(s) tested; .NET runtime tested

Windows 10 Pro 1909 - .NET CLR Version v4.0.30319

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

調査の方向性

Repository.IsValid から開始し、Proxy.git_repository_open_ext を経由して NativeMethods.git_repository_open_ext まで呼び出しを追跡してから、git_repository_free が関係するネイティブのエラーパスを調べます。Windows で壊れた .git/config のケースを再現し、アクセス違反ではなく LibGit2SharpException が発生することを確認します。既存のテスト配置から適切な場所が判断できる場合は、このシナリオのカバレッジを追加または更新します。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
csharp, git
領域
tooling
issue の種類
バグ
難易度
3/5
見積もり時間
1〜2日
活発さ
停滞
明瞭さ
おおむね明確
初心者へのやさしさ
45/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。