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
Touch seeded packages, which is subscribed to apport in 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

Status in apport package in Ubuntu:
  Confirmed
Status in apport source package in Impish:
  Confirmed
Status in apport source package in Jammy:
  Confirmed

Bug description:
  The Ubuntu Error Tracker has been receiving reports about a problem regarding 
apport.  This problem was most recently seen with package version 
2.20.11-0ubuntu70, the problem page at 
https://errors.ubuntu.com/problem/7120f8aebdf09e9dca39196d035eec234071e800 
contains more details, including versions of packages affected, stacktrace or 
traceback, and individual crash reports.
  If you do not have access to the Ubuntu Error Tracker and are a software 
developer, you can request it at http://forms.canonical.com/reports/.

  Traceback (most recent call last):
    File "/usr/share/apport/whoopsie-upload-all", line 196, in <module>
      stamps = collect_info()
    File "/usr/share/apport/whoopsie-upload-all", line 146, in collect_info
      res = process_report(r)
    File "/usr/share/apport/whoopsie-upload-all", line 103, in process_report
      r.add_gdb_info()
    File "/usr/lib/python3/dist-packages/apport/report.py", line 786, in 
add_gdb_info
      gdb_cmd, environ = self.gdb_command(rootdir, gdb_sandbox)
    File "/usr/lib/python3/dist-packages/apport/report.py", line 1706, in 
gdb_command
      self['CoreDump'].write(f)
    File "/usr/lib/python3/dist-packages/problem_report.py", line 75, in write
      block = gz.read(1048576)
    File "/usr/lib/python3.9/gzip.py", line 300, in read
      return self._buffer.read(size)
    File "/usr/lib/python3.9/_compression.py", line 68, in readinto
      data = self.read(len(byte_view))
    File "/usr/lib/python3.9/gzip.py", line 495, in read
      uncompress = self._decompressor.decompress(buf, size)
  zlib.error: Error -3 while decompressing data: invalid code lengths set

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


-- 
Mailing list: https://launchpad.net/~touch-packages
Post to     : touch-packages@lists.launchpad.net
Unsubscribe : https://launchpad.net/~touch-packages
More help   : https://help.launchpad.net/ListHelp

Reply via email to