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

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStan Hu <stanhu@gmail.com>2018-11-27 00:42:11 +0300
committerStan Hu <stanhu@gmail.com>2018-11-27 01:14:16 +0300
commite36c347ff9827d6d14c6a8b9e217e085a3c3a498 (patch)
tree4f1beb5e2498fb3a8369c3f17e27118d5146b8d6 /spec/lib/gitlab/git_ref_validator_spec.rb
parentdeaf3af7e5f357f3e8d91f7f2d49ad3ce001ba68 (diff)
Gracefully handle references with null bytes
`Rugged::Reference.valid_name?` used in `Gitlab::GitRefValidator.validate` fails on strings containing null bytes because it uses `StringValueCStr()`. Per https://silverhammermba.github.io/emberb/c/: Ruby’s String kinda corresponds to C’s char*. The simplest macro is StringValueCStr() which returns a null-terminated char* for a String. The problem here is that a Ruby String might contain nulls - in which case StringValueCStr() will raise an ArgumentError! Closes https://gitlab.com/gitlab-org/gitlab-ce/issues/54466
Diffstat (limited to 'spec/lib/gitlab/git_ref_validator_spec.rb')
-rw-r--r--spec/lib/gitlab/git_ref_validator_spec.rb1
1 files changed, 1 insertions, 0 deletions
diff --git a/spec/lib/gitlab/git_ref_validator_spec.rb b/spec/lib/gitlab/git_ref_validator_spec.rb
index ba7fb168a3b..3ab04a1c46d 100644
--- a/spec/lib/gitlab/git_ref_validator_spec.rb
+++ b/spec/lib/gitlab/git_ref_validator_spec.rb
@@ -27,4 +27,5 @@ describe Gitlab::GitRefValidator do
it { expect(described_class.validate('-branch')).to be_falsey }
it { expect(described_class.validate('.tag')).to be_falsey }
it { expect(described_class.validate('my branch')).to be_falsey }
+ it { expect(described_class.validate("\xA0\u0000\xB0")).to be_falsey }
end