Checking an operand can append expressions, such as the cast that widens a mixed-width operand, and the array can move. expression_type returned a pointer into it, and the caller kept both that pointer and its own expression pointer across the next operand's check. The fuzzer found the read after free on a mutation of std/net_http_curl_linux.zi. The operand types are now copied into the call's buffers and the expression is looked up again after each operand. tests/fuzz/binary_operand_realloc.zi places the widening append on a capacity boundary; it failed under the sanitizers before this change. site/std.html is regenerated for the Windows std changes.
30 lines
664 B
Ziran
30 lines
664 B
Ziran
// Checking the right operand widens a, appending a cast that can move the
|
|
// expression array while the == above it still points into it. Each padding
|
|
// line adds two expressions, so one of these lands on a capacity boundary.
|
|
Widen1 :: (a: s32, b: s64, x: s64) -> bool {
|
|
p: s64 = 0
|
|
p = 1
|
|
return x == a + b
|
|
}
|
|
Widen2 :: (a: s32, b: s64, x: s64) -> bool {
|
|
p: s64 = 0
|
|
p = 1
|
|
p = 1
|
|
return x == a + b
|
|
}
|
|
Widen3 :: (a: s32, b: s64, x: s64) -> bool {
|
|
p: s64 = 0
|
|
p = 1
|
|
p = 1
|
|
p = 1
|
|
return x == a + b
|
|
}
|
|
Widen4 :: (a: s32, b: s64, x: s64) -> bool {
|
|
p: s64 = 0
|
|
p = 1
|
|
p = 1
|
|
p = 1
|
|
p = 1
|
|
return x == a + b
|
|
}
|