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-10-19 03:01:55 +0300
committerStan Hu <stanhu@gmail.com>2018-10-19 09:15:24 +0300
commit4c4d1b792867195920fb6d6fb41cfa03a99cd299 (patch)
treebf5124452dc3de0871d22e931f4ab6466942e2a2 /lib/gitlab/ci
parent5edf87d0ac699575421ec96cbc0fc91ea0c3c078 (diff)
Fix EOF detection with CI artifacts metadata
There are some corner cases where a perfectly correct GZIP stream may not hit the EOF until another read is attempted. We now skip the entry if we don't see any valid data, which allows the EOF check to work properly. Closes https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/22479
Diffstat (limited to 'lib/gitlab/ci')
-rw-r--r--lib/gitlab/ci/build/artifacts/metadata.rb7
1 files changed, 5 insertions, 2 deletions
diff --git a/lib/gitlab/ci/build/artifacts/metadata.rb b/lib/gitlab/ci/build/artifacts/metadata.rb
index 375d8bc1ff5..551d4f4473e 100644
--- a/lib/gitlab/ci/build/artifacts/metadata.rb
+++ b/lib/gitlab/ci/build/artifacts/metadata.rb
@@ -59,9 +59,12 @@ module Gitlab
until gz.eof?
begin
- path = read_string(gz).force_encoding('UTF-8')
- meta = read_string(gz).force_encoding('UTF-8')
+ path = read_string(gz)&.force_encoding('UTF-8')
+ meta = read_string(gz)&.force_encoding('UTF-8')
+ # We might hit an EOF while reading either value, so we should
+ # abort if we don't get any data.
+ next unless path && meta
next unless path.valid_encoding? && meta.valid_encoding?
next unless path =~ match_pattern
next if path =~ INVALID_PATH_PATTERN