Project

General

Profile

Actions

Bug #10961

closed

Zlib corrupts data when receive signal

Added by leiting (Lei Ting) over 7 years ago. Updated 4 months ago.

Status:
Closed
Priority:
Normal
Assignee:
-
Target version:
-
ruby -v:
2.0.0-p353 2.2.0
[ruby-core:<unknown>]

Description

When receiving signal on main thread, Zlib::Deflate.deflate will be interrupted in zstream_run_func (zlib.c), thus producing unfinished output buffer.

Zlib::Deflate.deflate will return normally, without error, but the return value will be corrupted buffer and can't be decompressed.

Preferred fix: zstream_run() should check if err is Z_STREAM_END, if not, raise an error instead of return normally.


run zlib.rb to reproduce this problem:

ruby zlib.rb

37028
generating len=1000000000 string...
string length=1000000000
compressing...
^CINT (press Ctrl+C or send a signal to the pid)
zlib.rb:13:in deflate': data error (Zlib::DataError) from zlib.rb:13:in test_string'
from zlib.rb:25:in block in <main>' from zlib.rb:25:in each'
from zlib.rb:25:in `'


Files

zlib.rb (646 Bytes) zlib.rb leiting (Lei Ting), 03/11/2015 08:15 AM
bug10961.rb (312 Bytes) bug10961.rb wanabe (_ wanabe), 03/05/2021 07:47 AM
Actions

Also available in: Atom PDF