Skip to content

Commit 31898bb

Browse files
committed
isBlob: avoid panic on invalid path
The array access of `elem[len(elem)-1]` can be invalid if `len(elem) == 0`.
1 parent e075f20 commit 31898bb

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

pkg/registry/blobs.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,9 @@ import (
3838
func isBlob(req *http.Request) bool {
3939
elem := strings.Split(req.URL.Path, "/")
4040
elem = elem[1:]
41+
if len(elem) < 3 {
42+
return false
43+
}
4144
if elem[len(elem)-1] == "" {
4245
elem = elem[:len(elem)-1]
4346
}

0 commit comments

Comments
 (0)