libgit2 / libgit2/libgit2sharp

Crash calling Repository.IsValid with corrupt .git/config

未關閉
#1,851 0 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視

還沒有人認領這個 Issue。

主要語言
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. Fork 儲存庫,在一個分支上完成修改。
  4. 送出 Pull Request,並在描述裡引用這個 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 摘要。