Skip to content

Commit d67638a

Browse files
Use a faster test for LLVMFuzzerTestOneInput (swiftlang#31842)
1 parent 3280bf8 commit d67638a

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

validation-test/Sanitizers/fuzzer.swift

+3-2
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,10 @@ import MSVCRT
1717
#endif
1818

1919
@_cdecl("LLVMFuzzerTestOneInput")
20-
public func test(_ start: UnsafeRawPointer, _ count: Int) -> CInt {
20+
public func testHexDigits(_ start: UnsafeRawPointer, _ count: Int) -> CInt {
2121
let bytes = UnsafeRawBufferPointer(start: start, count: count)
22-
if bytes.starts(with: "ABC".utf8) {
22+
let string = String(decoding: bytes, as: Unicode.UTF8.self)
23+
if let number = Int(string, radix: 16), (0x10...0xFF).contains(number) {
2324
print("Crash!")
2425
fflush(stdout)
2526
exit(EXIT_FAILURE)

0 commit comments

Comments
 (0)