sealevel: modify memcmp syscall
This commit is contained in:
parent
3fb95e2b95
commit
068ff9301d
Binary file not shown.
|
@ -313,10 +313,10 @@ func TestInterpreter_Memcmp_Matches(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// The TestInterpreter_Memcmp_Does_Not_Match function tests that the memcmp
|
// The TestInterpreter_Memcmp_Does_Not_Match function tests that the memcmp
|
||||||
// syscall works as expected by comparing the string literals "abcdabcd1234"
|
// syscall works as expected by comparing the string literals "Bbcdabcd1234"
|
||||||
// and "BLAHabcd1234"
|
// and "aLAHabcd1234"
|
||||||
// The expected result is that the two strings do not match and the difference
|
// The expected result is that the two strings do not match and the difference
|
||||||
// between the first non-matching characters (0x61 - 0x42 = 0x1f) is returned,
|
// between the first non-matching characters (0x42 - 0x61 = -0x1f) is returned,
|
||||||
// and the program checks these and returns messages accordingly.
|
// and the program checks these and returns messages accordingly.
|
||||||
func TestInterpreter_Memcmp_Does_Not_Match(t *testing.T) {
|
func TestInterpreter_Memcmp_Does_Not_Match(t *testing.T) {
|
||||||
loader, err := loader.NewLoaderFromBytes(fixtures.Load(t, "sbpf", "memcmp_not_matched.so"))
|
loader, err := loader.NewLoaderFromBytes(fixtures.Load(t, "sbpf", "memcmp_not_matched.so"))
|
||||||
|
|
|
@ -87,7 +87,7 @@ func SyscallMemcmpImpl(vm sbpf.VM, addr1, addr2, n, resultAddr uint64, cuIn int)
|
||||||
b1 := slice1[count]
|
b1 := slice1[count]
|
||||||
b2 := slice2[count]
|
b2 := slice2[count]
|
||||||
if b1 != b2 {
|
if b1 != b2 {
|
||||||
cmpResult = int32(b1 - b2)
|
cmpResult = int32(b1) - int32(b2)
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue