Skip to content

UploadSourceLocalFileRange accepts a negative offset or one past the end of the file #665

Open

Description

@sophiecarreras

What happens

With length=None, the range source computes content_length = file_size - offset without checking offset. A negative offset or an offset beyond the file size gives an oversized or negative content_length.

Where

b2sdk/_internal/transfer/outbound/upload_source.py:181-187 (UploadSourceLocalFileRange.__init__).

Why it matters

Impact: Wrong request or result, silent. Severity: Low, because it needs invalid arguments from the caller, and no concrete break is shown.

How to check

Construct UploadSourceLocalFileRange(path, offset=file_size + 10) and read content_length. 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