Commit 4c4d1b79 authored by Stan Hu's avatar Stan Hu

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
parent 5edf87d0
---
title: Fix EOF detection with CI artifacts metadata
merge_request: 22479
author:
type: fixed
...@@ -59,9 +59,12 @@ module Gitlab ...@@ -59,9 +59,12 @@ module Gitlab
until gz.eof? until gz.eof?
begin begin
path = read_string(gz).force_encoding('UTF-8') path = read_string(gz)&.force_encoding('UTF-8')
meta = 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.valid_encoding? && meta.valid_encoding?
next unless path =~ match_pattern next unless path =~ match_pattern
next if path =~ INVALID_PATH_PATTERN next if path =~ INVALID_PATH_PATTERN
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment