Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

contract extend panics on single-change resultMetaXdr (index out of bounds at extend.rs:306)

Aperta Adatta ai principianti
#2,796 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
1/5
Tempo stimato
Meno di un'ora
Idoneità per principianti
90/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
rust
Ambito
cli

Direzione di ricerca

Parti da cmd/soroban-cli/src/commands/contract/extend.rs:306, dove il match indicizza &changes[0] e &changes[1] dopo le guardie di vuoto; sostituiscilo con un pattern di slice (o riutilizza parse_changes() da restore.rs) in modo che un meta con una singola modifica restituisca Error::LedgerEntryNotFound invece di andare in panic. Aggiungi un test di regressione con un result meta con una sola LedgerEntryChange, che rispecchi extend_nonexistent_entry_errors_without_panic, ed esegui la suite di test extend per confermare che non ci sia alcun index out of bounds.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

stellar contract extend reports the new liveUntilLedgerSeq by reading getTransaction.resultMetaXdr and inspecting operations[0].changes. After guarding operations.is_empty() and changes.is_empty(), it does match (&changes[0], &changes[1]) at cmd/soroban-cli/src/commands/contract/extend.rs:306. A meta whose single operation carries exactly one LedgerEntryChange passes both guards and panics with index out of bounds: the len is 1 but the index is 1.

The panic happens in the result-reporting phase, after the transaction has already been signed and submitted, so the operator sees a crash instead of the new TTL even when the on-chain extend may have succeeded.

PR #2657 added the equivalent guard for the length-zero case (.first().ok_or(Error::LedgerEntryNotFound)?) but left the length-one arm at line 306 reachable.

Fix

Bound the match instead of indexing, reusing the existing error:

let [first, second] = &changes[..] else {
    return Err(Error::LedgerEntryNotFound);
};
match (first, second) {

Alternatively, reuse restore.rs's iterator-based parse_changes(), which handles all lengths without indexing. A regression test with a single-change meta (asserting no panic / no index out of bounds) should accompany the fix, mirroring extend_nonexistent_entry_errors_without_panic.

Notes

This was surfaced via a security report and triaged as a non-security robustness bug: the panic is a safe bounds-checked Rust abort reachable only from a hostile/compromised RPC endpoint, with no memory-safety, data-disclosure, or integrity impact (crash only, after submission).

Lingua principale
Rust
Stelle
128
Fork
147
Merge medio
2g 12h
PR unite (30g)
35

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di stellar/stellar-cli

Tutte le issue di stellar/stellar-cli

Issue simili

Altre issue su Rust

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.