Skip to content
This repository has been archived by the owner on Jan 22, 2025. It is now read-only.

Commit

Permalink
Cleanup feature gate of stop_truncating_strings_in_syscalls.
Browse files Browse the repository at this point in the history
  • Loading branch information
Lichtso committed Jan 18, 2024
1 parent 8f9d915 commit 09363a6
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 21 deletions.
3 changes: 0 additions & 3 deletions programs/bpf_loader/src/syscalls/logging.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,6 @@ declare_builtin_function!(
addr,
len,
invoke_context.get_check_aligned(),
invoke_context
.feature_set
.is_active(&stop_truncating_strings_in_syscalls::id()),
&mut |string: &str| {
stable_log::program_log(&invoke_context.get_log_collector(), string);
Ok(0)
Expand Down
21 changes: 3 additions & 18 deletions programs/bpf_loader/src/syscalls/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,7 @@ use {
enable_big_mod_exp_syscall, enable_partitioned_epoch_reward, enable_poseidon_syscall,
error_on_syscall_bpf_function_hash_collisions, last_restart_slot_sysvar,
reject_callx_r10, remaining_compute_units_syscall_enabled,
stop_sibling_instruction_search_at_parent, stop_truncating_strings_in_syscalls,
switch_to_new_elf_parser,
stop_sibling_instruction_search_at_parent, switch_to_new_elf_parser,
},
hash::{Hash, Hasher},
instruction::{
Expand Down Expand Up @@ -567,22 +566,12 @@ fn translate_string_and_do(
addr: u64,
len: u64,
check_aligned: bool,
stop_truncating_strings_in_syscalls: bool,
work: &mut dyn FnMut(&str) -> Result<u64, Error>,
) -> Result<u64, Error> {
let buf = translate_slice::<u8>(memory_mapping, addr, len, check_aligned)?;
let msg = if stop_truncating_strings_in_syscalls {
buf
} else {
let i = match buf.iter().position(|byte| *byte == 0) {
Some(i) => i,
None => len as usize,
};
buf.get(..i).ok_or(SyscallError::InvalidLength)?
};
match from_utf8(msg) {
match from_utf8(buf) {
Ok(message) => work(message),
Err(err) => Err(SyscallError::InvalidString(err, msg.to_vec()).into()),
Err(err) => Err(SyscallError::InvalidString(err, buf.to_vec()).into()),
}
}

Expand Down Expand Up @@ -625,9 +614,6 @@ declare_builtin_function!(
file,
len,
invoke_context.get_check_aligned(),
invoke_context
.feature_set
.is_active(&stop_truncating_strings_in_syscalls::id()),
&mut |string: &str| Err(SyscallError::Panic(string.to_string(), line, column).into()),
)
}
Expand Down Expand Up @@ -2158,7 +2144,6 @@ mod tests {
0x100000000,
string.len() as u64,
true,
true,
&mut |string: &str| {
assert_eq!(string, "Gaggablaghblagh!");
Ok(42)
Expand Down

0 comments on commit 09363a6

Please sign in to comment.