Skip to content

UploadSourceStream opens a stream to compute its SHA1 and never closes it #653

Open

Description

@sophiecarreras

What happens

When the checksum or length of a stream-based upload source is needed, hex_sha1_of_unlimited_stream(self.open()) is called on a stream that is never closed. On CPython the object is usually closed promptly by reference counting, but on other runtimes or with custom stream openers the handle can stay open.

Where

b2sdk/_internal/transfer/outbound/upload_source.py:318-321 (_set_content_length_and_sha1, line 319).

Why it matters

Impact: Left behind (resource not released), silent. Severity: Low, because on CPython the stream is normally released straight away, so no concrete leak is shown.

How to check

Use a stream_opener that returns a stream recording close() calls, request get_content_sha1(), and check that close() is not called. Found by reading the code, not reproduced.

Version

Seen at v2.13.4. Present on the default branch: present.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions