Repository navigation
fix(executor): clamp the $() and backtick raw-skip copy loops to the buffer (#875) - #877
Merged
Merged
Conversation
…buffer (#875) mark_literal_ifs_chars copies $(...) and backtick bodies with the skip_raw_* helpers' return value as an exclusive bound. Those helpers return beyond-the-buffer sentinels when an unclosed span ends in a trailing backslash (skip_raw_quote/skip_raw_backtick do index += 2 on the escape hop): the word $("a\ makes skip_raw_command_substitution return len+1, and the unclamped copy loop indexes chars[len] and panics the whole shell — thread 'niu-main' panicked at executor/command_prepare.rs:3919:46 'index out of bounds: the len is N but the index is N' (release-journey P7 panic, niubash release run 39233051251; every session boot after a wizard theme pick died). The braced-parameter branch got exactly this clamp in the #743 followup (probe 2026-10-18, same panic class); the $() and backtick branches were missed. Clamp both the same way: an unclosed body is copied verbatim, which is exactly what the word contains at this stage.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #875. 发版阻塞修复,随 niubash v1.4.1 re-release 走(niubash 侧将把 scripts/release/rubash-pin.json 顶到本 PR 的 commit;merge 先于 re-tag)。
变更
mark_literal_ifs_chars的$(...)分支(command_prepare.rs:3917 一带)与反引号分支(:3947 一带)的 copy 循环,上界同样.min(chars.len())clamp——与 braced 分支 a partially-quoted word is treated as wholly quoted, so field splitting is skipped and the argument count is wrong #743 followup(:3879,probe 2026-10-18,同一 panic 类)完全同款。未闭合体按原样逐字拷贝。$("a\(未闭合$(+ 引号尾随反斜杠)不再 panic(补丁前红:command_prepare.rs:3919:46, the len is 5 but the index is 5,与 release journey 崩溃同形;run 39233051251 的真实案例 len=132);`a\(未闭合反引号 + 尾随反斜杠)不再 panic(补丁前红 :3949:34);验证
关联