aboutsummaryrefslogtreecommitdiffstats
path: root/ext
diff options
context:
space:
mode:
Diffstat (limited to 'ext')
-rw-r--r--ext/zlib/zlib.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/ext/zlib/zlib.c b/ext/zlib/zlib.c
index 08963a923e..a235cbb621 100644
--- a/ext/zlib/zlib.c
+++ b/ext/zlib/zlib.c
@@ -2306,6 +2306,9 @@ gzfile_read_header(struct gzfile *gz)
zstream_discard_input(&gz->z, 2 + len);
}
if (flags & GZ_FLAG_ORIG_NAME) {
+ if (!gzfile_read_raw_ensure(gz, 1)) {
+ rb_raise(cGzError, "unexpected end of file");
+ }
p = gzfile_read_raw_until_zero(gz, 0);
len = p - RSTRING_PTR(gz->z.input);
gz->orig_name = rb_str_new(RSTRING_PTR(gz->z.input), len);
@@ -2313,6 +2316,9 @@ gzfile_read_header(struct gzfile *gz)
zstream_discard_input(&gz->z, len + 1);
}
if (flags & GZ_FLAG_COMMENT) {
+ if (!gzfile_read_raw_ensure(gz, 1)) {
+ rb_raise(cGzError, "unexpected end of file");
+ }
p = gzfile_read_raw_until_zero(gz, 0);
len = p - RSTRING_PTR(gz->z.input);
gz->comment = rb_str_new(RSTRING_PTR(gz->z.input), len);