Skip to content

OOB string indexing panic with incorrect Cargo.toml #13374

Closed
@Nemo157

Description

@Nemo157

Problem

When mistyping a Cargo.toml cargo panics when attempting to parse it

Steps

  1. Create a Cargo.toml with
[package]
name = "foo"
version = "0.1.0"
edition = "2021"
[[bench.foo]]
  1. cargo check:
thread 'main' panicked at src/cargo/util/toml/mod.rs:124:38:
byte index 18446744073709551615 is out of bounds of `[package]
name = "foo"
version = "0.1.0"
edition = "2021"
[[bench.foo]]
`
stack backtrace:
   0: rust_begin_unwind
             at /rustc/098d4fd74c078b12bfc2e9438a2a04bc18b393bc/library/std/src/panicking.rs:647:5
   1: core::panicking::panic_fmt
             at /rustc/098d4fd74c078b12bfc2e9438a2a04bc18b393bc/library/core/src/panicking.rs:72:14
   2: core::str::slice_error_fail_rt
   3: core::str::slice_error_fail
             at /rustc/098d4fd74c078b12bfc2e9438a2a04bc18b393bc/library/core/src/str/mod.rs:88:9
   4: cargo::util::toml::read_manifest
   5: <cargo::core::workspace::Packages>::load
   6: <cargo::core::workspace::Workspace>::find_root
   7: <cargo::core::workspace::Workspace>::new
   8: <clap_builder::parser::matches::arg_matches::ArgMatches as cargo::util::command_prelude::ArgMatchesExt>::workspace
   9: cargo::commands::check::exec
  10: cargo::cli::main
  11: cargo::main
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

Possible Solution(s)

No response

Notes

No response

Version

cargo 1.77.0-nightly (84976cd69 2024-01-12)
release: 1.77.0-nightly
commit-hash: 84976cd699f4aea56cb3a90ce3eedeed9e20d5a5
commit-date: 2024-01-12
host: x86_64-unknown-linux-gnu
libgit2: 1.7.1 (sys:0.18.1 vendored)
libcurl: 8.5.0-DEV (sys:0.4.70+curl-8.5.0 vendored ssl:OpenSSL/1.1.1w)
ssl: OpenSSL 1.1.1w  11 Sep 2023
os: NixOS 23.11.0 [64-bit]

Metadata

Metadata

Assignees

Labels

A-diagnosticsArea: Error and warning messages generated by Cargo itself.C-bugCategory: bugS-acceptedStatus: Issue or feature is accepted, and has a team member available to help mentor or review

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions