mirror of
https://github.com/fish-shell/fish-shell.git
synced 2026-06-02 05:41:16 -03:00
Fix buffer overflow accessing error source in ParseError::describe()
For some reason this error is triggered by tests after the Rust port of ast.cpp. Might want to get to the bottom of this but moving it back to match the original C++ logic fixes it.
This commit is contained in:
@@ -392,18 +392,21 @@ pub fn describe_with_prefix(
|
||||
skip_caret: bool,
|
||||
) -> WString {
|
||||
let mut result = prefix.to_owned();
|
||||
let context = wstr::from_char_slice(
|
||||
&src.as_char_slice()[self.source_start..self.source_start + self.source_length],
|
||||
);
|
||||
// Some errors don't have their message passed in, so we construct them here.
|
||||
// This affects e.g. `eval "a=(foo)"`
|
||||
match self.code {
|
||||
ParseErrorCode::andor_in_pipeline => {
|
||||
let context = wstr::from_char_slice(
|
||||
&src.as_char_slice()[self.source_start..self.source_start + self.source_length],
|
||||
);
|
||||
result += wstr::from_char_slice(
|
||||
wgettext_fmt!(INVALID_PIPELINE_CMD_ERR_MSG, context).as_char_slice(),
|
||||
);
|
||||
}
|
||||
ParseErrorCode::bare_variable_assignment => {
|
||||
let context = wstr::from_char_slice(
|
||||
&src.as_char_slice()[self.source_start..self.source_start + self.source_length],
|
||||
);
|
||||
let assignment_src = context;
|
||||
#[allow(clippy::explicit_auto_deref)]
|
||||
let equals_pos = variable_assignment_equals_pos(assignment_src).unwrap();
|
||||
|
||||
Reference in New Issue
Block a user