Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitaly.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Okstad <pokstad@gitlab.com>2019-08-13 01:18:33 +0300
committerJohn Cai <jcai@gitlab.com>2019-08-13 01:18:33 +0300
commit0ec00f843cf878673934877d8a6194d98cfd9318 (patch)
treeff4b66c656b23b8a873350576214b447f666a255 /internal/git
parentc6d201ee96ddc917ba0a94bf2fa5cea0e0627155 (diff)
Fix FindCommits flag injection exploit
Diffstat (limited to 'internal/git')
-rw-r--r--internal/git/proto.go16
1 files changed, 13 insertions, 3 deletions
diff --git a/internal/git/proto.go b/internal/git/proto.go
index 5244e6bdb..17323c600 100644
--- a/internal/git/proto.go
+++ b/internal/git/proto.go
@@ -18,9 +18,8 @@ import (
// See https://gitlab.com/gitlab-org/gitaly/issues/556#note_40289573
var FallbackTimeValue = time.Unix(1<<63-62135596801, 999999999)
-// ValidateRevision checks if a revision looks valid
-func ValidateRevision(revision []byte) error {
- if len(revision) == 0 {
+func validateRevision(revision []byte, allowEmpty bool) error {
+ if !allowEmpty && len(revision) == 0 {
return fmt.Errorf("empty revision")
}
if bytes.HasPrefix(revision, []byte("-")) {
@@ -38,6 +37,17 @@ func ValidateRevision(revision []byte) error {
return nil
}
+// ValidateRevisionAllowEmpty checks if a revision looks valid, but allows
+// empty strings
+func ValidateRevisionAllowEmpty(revision []byte) error {
+ return validateRevision(revision, true)
+}
+
+// ValidateRevision checks if a revision looks valid
+func ValidateRevision(revision []byte) error {
+ return validateRevision(revision, false)
+}
+
// Version returns the used git version.
func Version() (string, error) {
ctx, cancel := context.WithCancel(context.Background())