Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.openwrt.org/project/libubox.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorPetr Štetiar <ynezz@true.cz>2019-12-11 08:35:17 +0300
committerPetr Štetiar <ynezz@true.cz>2019-12-25 12:31:58 +0300
commit586ce031eaa0e732603adbc9509aeaca4d6b2769 (patch)
tree5f1b93b7f425acdb64601d543a01e891f47692d3 /tests
parentb0e21553ae8c58d5db8103a0ea4d6095c6e4fe07 (diff)
tests: fuzz: fuzz _len variants of checking methods
In order to increase test coverage. Signed-off-by: Petr Štetiar <ynezz@true.cz>
Diffstat (limited to 'tests')
-rw-r--r--tests/fuzz/test-fuzz.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/tests/fuzz/test-fuzz.c b/tests/fuzz/test-fuzz.c
index 52f2bbc..4dc13a8 100644
--- a/tests/fuzz/test-fuzz.c
+++ b/tests/fuzz/test-fuzz.c
@@ -1,10 +1,13 @@
#include <stdio.h>
#include <stdint.h>
#include <stddef.h>
+#include <limits.h>
#include "blob.h"
#include "blobmsg.h"
+#define BLOBMSG_TYPE_TROUBLE INT_MAX
+
static void fuzz_blobmsg_parse(const uint8_t *data, size_t size)
{
enum {
@@ -14,6 +17,19 @@ static void fuzz_blobmsg_parse(const uint8_t *data, size_t size)
__FOO_MAX
};
+ static const int blobmsg_type[] = {
+ BLOBMSG_TYPE_UNSPEC,
+ BLOBMSG_TYPE_ARRAY,
+ BLOBMSG_TYPE_TABLE,
+ BLOBMSG_TYPE_STRING,
+ BLOBMSG_TYPE_INT64,
+ BLOBMSG_TYPE_INT32,
+ BLOBMSG_TYPE_INT16,
+ BLOBMSG_TYPE_INT8,
+ BLOBMSG_TYPE_DOUBLE,
+ BLOBMSG_TYPE_TROUBLE,
+ };
+
static const struct blobmsg_policy foo_policy[] = {
[FOO_MESSAGE] = {
.name = "message",
@@ -33,6 +49,14 @@ static void fuzz_blobmsg_parse(const uint8_t *data, size_t size)
blobmsg_parse(foo_policy, __FOO_MAX, tb, (uint8_t *)data, size);
blobmsg_parse_array(foo_policy, __FOO_MAX, tb, (uint8_t *)data, size);
+
+ blobmsg_check_attr_len((struct blob_attr *)data, false, size);
+ blobmsg_check_attr_len((struct blob_attr *)data, true, size);
+
+ for (size_t i=0; i < ARRAY_SIZE(blobmsg_type); i++) {
+ blobmsg_check_array_len((struct blob_attr *)data, blobmsg_type[i], size);
+ blobmsg_check_attr_list_len((struct blob_attr *)data, blobmsg_type[i], size);
+ }
}
static void fuzz_blob_parse(const uint8_t *data, size_t size)