[libc-commits] [PATCH] D150598: [libc] use LLVM atof for fuzz precheck
Michael Jones via Phabricator via libc-commits
libc-commits at lists.llvm.org
Mon May 15 11:23:50 PDT 2023
michaelrj created this revision.
michaelrj added reviewers: sivachandra, lntue.
Herald added subscribers: libc-commits, ecnelises, tschuett.
Herald added projects: libc-project, All.
michaelrj requested review of this revision.
The atof differential fuzz precheck skips all hexadecimal subnormals
since glibc's atof doesn't round them correctly. By using glibc's atof
to check if the number is a hexadecimal subnormal it was found that it
sometimes rounds down to zero when it should round up to the minimum
subnormal. This bypassed the check since 0 does not count as a
subnormal. This patch solves the issue by using the LLVM-libc
implementation of atof.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D150598
Files:
libc/fuzzing/stdlib/atof_differential_fuzz.cpp
Index: libc/fuzzing/stdlib/atof_differential_fuzz.cpp
===================================================================
--- libc/fuzzing/stdlib/atof_differential_fuzz.cpp
+++ libc/fuzzing/stdlib/atof_differential_fuzz.cpp
@@ -37,7 +37,9 @@
}
bool should_be_skipped(const uint8_t *str) {
- double init_result = ::atof(reinterpret_cast<const char *>(str));
+ // We can be more confident that our atof is correct than the system one, at
+ // least for this case.
+ double init_result = __llvm_libc::atof(reinterpret_cast<const char *>(str));
if (init_result < 0) {
init_result = -init_result;
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D150598.522277.patch
Type: text/x-patch
Size: 613 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libc-commits/attachments/20230515/c033095f/attachment.bin>
More information about the libc-commits
mailing list