aboutsummaryrefslogtreecommitdiff
path: root/src/include
diff options
context:
space:
mode:
authorIvan Nardi <12729895+IvanNardi@users.noreply.github.com>2023-01-27 07:09:18 +0100
committerGitHub <noreply@github.com>2023-01-27 07:09:18 +0100
commit6d00a9e0bd4cdb2be26577f53b75b3078cefd4c3 (patch)
tree327e7d1bc8e89a990e99ea8cfb4a748c80d12f32 /src/include
parenteea99564308fffca675918506a6e12f7a4f71a6f (diff)
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`)
Diffstat (limited to 'src/include')
-rw-r--r--src/include/ndpi_api.h20
1 files changed, 20 insertions, 0 deletions
diff --git a/src/include/ndpi_api.h b/src/include/ndpi_api.h
index d9e48047f..9968e9eb3 100644
--- a/src/include/ndpi_api.h
+++ b/src/include/ndpi_api.h
@@ -1253,6 +1253,16 @@ extern "C" {
* @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
+ * @param key The field name or ID
+ * @param value The field value
* @param format The double value format
* @return 0 on success, a negative number otherwise
*/
@@ -1277,6 +1287,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
* @param key The field name or ID