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

Cleanup - feature gate of stop_truncating_strings_in_syscalls #34842

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -39,8 +39,7 @@ use {
enable_alt_bn128_compression_syscall, enable_alt_bn128_syscall,
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_truncating_strings_in_syscalls, switch_to_new_elf_parser,
reject_callx_r10, remaining_compute_units_syscall_enabled, switch_to_new_elf_parser,
},
hash::{Hash, Hasher},
instruction::{AccountMeta, InstructionError, ProcessedSiblingInstruction},
Expand Down Expand Up @@ -563,22 +562,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 @@ -621,9 +610,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 @@ -2159,7 +2145,6 @@ mod tests {
0x100000000,
string.len() as u64,
true,
true,
&mut |string: &str| {
assert_eq!(string, "Gaggablaghblagh!");
Ok(42)
Expand Down