News for hackers. Stuff that matters.
Re:Fuzzing Zig Code Using AFL++ by tialaramex on Thursday September 23, 2021 @05:36PM (#28635816)
Presumably the string literals are zero-terminated but other slices aren't? In a language that doesn't have safety promises that feels like a bug waiting to happen, somebody's code "works" with all the string literal test inputs but alas, real slices sometimes aren't followed by a zero terminator and it blows up nastily.

And then also the same misfire can hurt in the other direction. Since Rust's str is really a UTF-8 slice, the zeroes are just zeroes, valid UTF-8 characters, you can ask if a Rust str contains(0 as char) because that's a completely reasonable question - but if your code thinks zero might be a "terminator" it can't actually handle arbitrary UTF-8 this way.

Actually I think this makes the call for an actual str built-in even more appropriate because Zig's owners would need to wrestle with this and work out what they intended whereas just saying []const u8 allows you to hide inconsistencies in the libraries and people will get bitten.

Re:Fuzzing Zig Code Using AFL++ by flohofwoe on Friday September 24, 2021 @06:33AM (#28640630)
Sentinel-terminated arrays and slices have a different type than regular arrays and slices, and the sentinel isn't the terminator for the array or slice, just an additional item past the end. I think it's reasonably type-safe:

https://ziglang.org/documentation/0.8.1/#Sentinel-Terminated...