arg_value_union panics on zero-arity union tuple case (unchecked type_[0] index)
Maintainer thường phản hồi trong vòng 1 ngày
Đá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
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ả
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, returningNonefor a zero-arity tuple case, matching thetype_.len() == 1guardexample_unionapplies. 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
- Không có Dockerfile hay tệp Docker Compose
- Có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- 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.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của stellar/stellar-cli
-
contract extend panics on single-change resultMetaXdr (index out of bounds at extend.rs:306)Có thể đã có người làm Có pull request liên kết đang mở hoặc đã được merge. Đang mở
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 90/100
stellar/stellar-cli#2796 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 1/5 1-3 giờ Mức phù hợp với người mới 85/100
stellar/stellar-cli#2781 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Display the full authorization tree before signing auth entriesCó thể đã có người làm @DeadZen đã nhận 19 ngày trước. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
stellar/stellar-cli#2779 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
`tx update sequence-number next` fails when the transaction source is a muxed accountCó thể làm lại được Pull request cho issue này đã bị đóng mà không được merge. Đang mởbug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
stellar/stellar-cli#2774 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
`tx edit` fails on transaction XDR that is wrapped across multiple linesCó thể đã có người làm @mangod12 đã nhận 4 ngày trước. Đang mởbug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
stellar/stellar-cli#2773 ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của stellar/stellar-cli
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
pedrovgs/UseCaseCoverage#23 ·
-
priority: low
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 64/100
storytold/photocraft#8687 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 2 ngày
-
THREAD: operation failedĐang mởarea:kernel bug kernel-paused needs-triage
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
bherbruck/solvecraft#5055 · 2 bình luận ·
-
bug cli p3
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
Maintainer thường phản hồi trong vòng 3 ngày
-
documentation good first issue help wanted
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
Maintainer thường phản hồi trong vòng 1 ngày