This is an archive of the discontinued LLVM Phabricator instance.

[libc] use vars in string to num fuzz targets
ClosedPublic

Authored by michaelrj on Feb 16 2023, 11:27 AM.

Details

Summary

The string to integer and string to float standalone fuzz targets just
ran the functions and didn't do anything with the output. This was
intentional, since they are intended to be used with sanitizers to
detect buffer overflow bugs. Not using the variables was causing compile
warnings, so this patch adds trivial checks to use the variables.

Diff Detail

Event Timeline

michaelrj created this revision.Feb 16 2023, 11:27 AM
Herald added projects: Restricted Project, Restricted Project. · View Herald TranscriptFeb 16 2023, 11:27 AM
michaelrj requested review of this revision.Feb 16 2023, 11:27 AM
lntue added inline comments.Feb 16 2023, 10:23 PM
libc/fuzzing/stdlib/strtofloat_fuzz.cpp
50

Maybe adding an inline function will help with readability here:

template <typename T>
LIBC_INLINE bool is_nan(T x) { return x != x; }
michaelrj updated this revision to Diff 498505.Feb 17 2023, 2:07 PM
michaelrj marked an inline comment as done.

move to is_nan function, and fix some typos in the comments

lntue accepted this revision.Feb 27 2023, 12:25 PM
This revision is now accepted and ready to land.Feb 27 2023, 12:25 PM
sivachandra added inline comments.Feb 27 2023, 12:26 PM
libc/fuzzing/stdlib/strtofloat_fuzz.cpp
20

LIBC_INLINE is to be used only in the src directory. Else, we are creating an unnecessary dependency.

53

If all of this is present to only silence a compiler warning, and if you really want to check isnan, you are better off using the isnan predicate from math.h.

michaelrj updated this revision to Diff 500893.Feb 27 2023, 1:14 PM
michaelrj marked 2 inline comments as done.

move to normal inline and isnan

sivachandra accepted this revision.Feb 27 2023, 1:19 PM
This revision was landed with ongoing or failed builds.Feb 27 2023, 1:21 PM
This revision was automatically updated to reflect the committed changes.