Bug analysis
============

whoopsie-upload-all reads the *.crash files (to upload them):

```
r = apport.Report()
with open(report, 'rb') as f:
    r.load(f, binary='compressed')
```

ProblemReport.load reads the encoded data and keeps in compressed:

```python
block = base64.b64decode(line)
if value.gzipvalue == b'' and not block.startswith(b'\037\213\010'):
    value.legacy_zlib = True
value.gzipvalue += block
```

Derived from the code path, `legacy_zlib` is set to `False` in this
case. Then `Report.gdb_command` tries to decompress the CoreDump field
and write it into a temporary file. The relevant part from
`problem_report.py` from apport 2.20.11-0ubuntu71 (line 73):

```python
gz = gzip.GzipFile(fileobj=BytesIO(self.gzipvalue))
while True:
    block = gz.read(1048576)
    if not block:
        break
    file.write(block)
```

So the only two reasons that I can see why decompressing the byte object 
`gzipvalue`:
1. The content of the CoreDump field in the .crash file is malformed.
2. `legacy_zlib` is set to `False` instead of `True`.

Reproduction
============

I tried to reproduce the `zlib.error` by feeding it with wrong data:

```
In [1]: import gzip

In [2]: from io import BytesIO

In [3]: gzip.GzipFile(fileobj=BytesIO(None)).read(1048576)
Out[3]: b''

In [4]: gzip.GzipFile(fileobj=BytesIO(b"")).read(1048576)
Out[4]: b''

In [5]: gzip.GzipFile(fileobj=BytesIO(b"bogus")).read(1048576)
[...]
BadGzipFile: Not a gzipped file (b'bo')
```

-- 
You received this bug notification because you are a member of Ubuntu
Bugs, which is subscribed to Ubuntu.
https://bugs.launchpad.net/bugs/1947800

Title:
  /usr/share/apport/whoopsie-upload-
  all:zlib.error:/usr/share/apport/whoopsie-upload-
  
all@196:collect_info:process_report:add_gdb_info:gdb_command:write:read:readinto:read

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/apport/+bug/1947800/+subscriptions


-- 
ubuntu-bugs mailing list
ubuntu-bugs@lists.ubuntu.com
https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs

Reply via email to