Skip to content

set_path panics on oversized input instead of returning an error #1106

@xc01

Description

@xc01
  • Note that this crate implements the URL Standard not RFC 1738 or RFC 3986

Describe the bug

Summary

Url::set_path can panic on extremely large input due to internal arithmetic overflow (in restore_after_path) instead of returning an error.

Reproduction

use url::Url;

fn main() {
    let mut url = Url::parse("http://a/?a#b").unwrap();

    let encoded_path_bytes_target = (u32::MAX as usize) - 9;
    let input_spaces = encoded_path_bytes_target / 3;
    let huge_path = " ".repeat(input_spaces);

    url.set_path(&huge_path); // panic (with overflow checks)
}

Expected

Graceful failure (e.g., Result error) for oversized input, not panic.

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