libgit2 / libgit2/libgit2sharp
Crash calling Repository.IsValid with corrupt .git/config
还没有人认领这个 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
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 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