aboutsummaryrefslogtreecommitdiffstats
path: root/repository_test.go
diff options
context:
space:
mode:
authorChristian Muehlhaeuser <muesli@gmail.com>2022-01-19 15:51:13 +0100
committerGitHub <noreply@github.com>2022-01-19 15:51:13 +0100
commit935af59cf64fbe49eb8baba9fe80e6b236daf593 (patch)
tree1c62876d621a2804568151f3d3d3cb5c0f246d2e /repository_test.go
parent1b36bebee9fa72b96e13ced3e18132644d34e6be (diff)
downloadgo-git-935af59cf64fbe49eb8baba9fe80e6b236daf593.tar.gz
Repository: don't crash accessing invalid pathinfo (#443)
When fs.Stat returns an error, pathinfo may be nil. In such situations the only safe response seems to be to return the error to the caller. Without this fix, accessing pathinfo.IsDir() below would lead to a crash dereferencing a nil pointer. This crash can be reproduced by trying to initialize a Git repo with an invalid path name. Also see: https://github.com/muesli/gitty/issues/36
Diffstat (limited to 'repository_test.go')
-rw-r--r--repository_test.go5
1 files changed, 5 insertions, 0 deletions
diff --git a/repository_test.go b/repository_test.go
index e284df8..7a9db15 100644
--- a/repository_test.go
+++ b/repository_test.go
@@ -2948,6 +2948,11 @@ func (s *RepositorySuite) TestBrokenMultipleShallowFetch(c *C) {
c.Assert(err, IsNil)
}
+func (s *RepositorySuite) TestDotGitToOSFilesystemsInvalidPath(c *C) {
+ _, _, err := dotGitToOSFilesystems("\000", false)
+ c.Assert(err, NotNil)
+}
+
func BenchmarkObjects(b *testing.B) {
defer fixtures.Clean()