fuzz: add a new fuzzer to test serialization/deserialization code (#1876)

Autodetecting the needed buffer size is quite complex (especially with
float/double values) so it is mandatory to properly check for
`ndpi_snprintf` truncation.
These issues have been undetected so far probably because the default
buffer is big enough for all common cases.

Add an example of usage of `ndpi_deserialize_clone_all()` (taken from
`ntopng`)
This commit is contained in:
Ivan Nardi
2023-01-27 07:09:18 +01:00
committed by GitHub
parent eea9956430
commit 6d00a9e0bd
144 changed files with 564 additions and 78 deletions
+20
View File
@@ -1248,6 +1248,16 @@ extern "C" {
*/
int ndpi_serialize_uint32_float(ndpi_serializer *serializer, u_int32_t key, float value, const char *format /* e.f. "%.2f" */);
/**
* Serialize a 32-bit unsigned int key and a double value
* @param serializer The serializer handle
* @param key The field name or ID
* @param value The field value
* @param format The float value format
* @return 0 on success, a negative number otherwise
*/
int ndpi_serialize_uint32_double(ndpi_serializer *serializer, u_int32_t key, double value, const char *format /* e.f. "%.2f" */);
/**
* Serialize a 32-bit unsigned int key and a double value
* @param serializer The serializer handle
@@ -1276,6 +1286,16 @@ extern "C" {
*/
int ndpi_serialize_uint32_boolean(ndpi_serializer *serializer, u_int32_t key, u_int8_t value);
/**
* Serialize a 32-bit unsigned int and an unterminated string value
* @param serializer The serializer handle
* @param key The field name or ID
* @param value The field value
* @param vlen The value length
* @return 0 on success, a negative number otherwise
*/
int ndpi_serialize_uint32_binary(ndpi_serializer *serializer, u_int32_t key, const char *_value, u_int16_t vlen);
/**
* Serialize an unterminated string key and a 32-bit signed int value
* @param serializer The serializer handle