pub fn sol_memcmp(s1: &[u8], s2: &[u8], n: usize) -> i32
Expand description

Like C memcmp.

Arguments

  • s1 - Slice to be compared
  • s2 - Slice to be compared
  • n - Number of bytes to compare

Errors

When executed within a BPF program, the memory regions spanning n bytes from from the start of dst and src must be mapped program memory. If not, the program will abort.

Safety

This function is incorrectly missing an unsafe declaration.

It does not verify that n is less than or equal to the lengths of the dst and src slices passed to it — it will read bytes beyond the slices.

Specifying an n greater than either the length of dst or src will likely introduce undefined behavior.