Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

arg_value_union panics on zero-arity union tuple case (unchecked type_[0] index)

Đang mở Phù hợp với người mới
#2,806 1 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

@hvoi đang làm issue này rồi.

Từ ngày 21/10/2026.

  • #2813 của @hvoi — đang mở

Đánh giá

Độ khó
2/5
Thời gian dự kiến
1-3 giờ
Mức phù hợp với người mới
72/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
rust
Lĩnh vực
cli

Hướng nghiên cứu

Panic nằm trong arg_value_union trong cmd/crates/soroban-spec-tools/src/lib.rs, quanh các dòng 1326-1342, bên trong nhánh depth > 1 nơi type_[0] được truy cập theo chỉ số mà không kiểm tra độ dài. So sánh với điều kiện bảo vệ type_.len() == 1 trong example_union, gần dòng 1517. Để tái hiện, hãy tạo một spec có trường hợp tuple union với arity bằng không bên trong Option<Vec<MyUnion>> rồi chạy contract invoke -- --help. Hoàn thành khi trường hợp arity bằng không trả về None thay vì panic, và có một test bao phủ nó.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

bug

cmd/crates/soroban-spec-tools/src/lib.rs:1326-1342 indexes type_[0] inside the depth > 1 branch of arg_value_union without a length check. A contract spec whose union TupleV0 case declares an empty type_ (a VecM<ScSpecTypeDef> of length 0, which is valid XDR) causes an out-of-bounds panic while the clap command is being constructed.

Introduced by #1593, which replaced the non-indexing type_.iter().map(...) with a depth guard that indexes directly. The sibling example_union already guards the identical shape with type_.len() == 1 (~line 1517), which confirms the missing check is an oversight.

Reach

The expansion runs for every function during build_clap_command, so contract invoke --id <c> -- --help is sufficient to trigger it; contract deploy --wasm-hash reaches the same code via the constructor path. contract info interface is unaffected. The union must sit at least two type levels deep to enter the depth > 1 branch, e.g. an input typed Option<Vec<MyUnion>>.

Fix

  • Add a length check before indexing in arg_value_union, returning None for a zero-arity tuple case, matching the type_.len() == 1 guard example_union applies. This covers all three index sites (:1327, :1338, :1342).
  • Reject a zero-arity union tuple case during spec decode/verify so every consumer is protected at once rather than each rendering path separately.
Ngôn ngữ chính
Rust
Star
128
Fork
147
Merge trung bình
2 ngày 12 giờ
Pull request đã merge (30 ngày)
35

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của stellar/stellar-cli

Tất cả issue của stellar/stellar-cli

Issue tương tự

Thêm issue về Rust

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.