|
BDE 4.39.x Production Release
|
Provide creation of bdlt data types from fuzz data.
Provide creation of bdlt data types from fuzz data.
bdlt data types from fuzz dataThis component defines a struct, bdlt::FuzzUtil, which serves as a namespace for functions to create bdlt date and time types from supplied fuzz input data.
Effectively, given a random sequence of bytes provided by a fuzz harness, like libFuzzer, this component can be used to generate arbitrary date and time values determined by that random sequence. This can be used to fuzz test an interface using date/time values. See the BDE fuzz-testing guide for more detail.
The operations to produce date and time types allow restrictions on ranges of dates to be produced, since it is common for operations to be valid only on a certain range of dates. The same is not typically true for time and time-zone offset, so operations that restrict the range of values produced for those attributes are not currently provided.
This section illustrates intended use of this component.
The provided fuzz data is here represented by an array of bytes:
First, we default construct a bslim::FuzzDataView object, fdv:
Next, we construct Date objects to represent the begin and end of the time interval in which we wish to construct our new Date from the fuzz data:
Finally, we create a Date object, within, by employing bdlt_fuzzutil :