diff --git a/fuzzing/afl.c b/fuzzing/afl.c index f2452def260ae85723172126ab8affde01e46d61..59bbca79496dc78e86e50dd4ada38523b54841cb 100644 --- a/fuzzing/afl.c +++ b/fuzzing/afl.c @@ -101,12 +101,12 @@ int main(int argc, char** argv) filename = argv[1]; json = read_file(filename); - if (json == NULL) + if ((json == NULL) || (json[0] == '\0') || (json[1] == '\0')) { status = EXIT_FAILURE; goto cleanup; } - item = cJSON_Parse(json); + item = cJSON_Parse(json + 2); if (item == NULL) { goto cleanup; @@ -114,7 +114,29 @@ int main(int argc, char** argv) if ((argc == 3) && (strncmp(argv[2], "yes", 3) == 0)) { - printed_json = cJSON_Print(item); + int do_format = 0; + if (json[1] == 'f') + { + do_format = 1; + } + + if (json[0] == 'b') + { + /* buffered printing */ + printed_json = cJSON_PrintBuffered(item, 1, do_format); + } + else + { + /* unbuffered printing */ + if (do_format) + { + printed_json = cJSON_Print(item); + } + else + { + printed_json = cJSON_PrintUnformatted(item); + } + } if (printed_json == NULL) { status = EXIT_FAILURE; diff --git a/fuzzing/inputs/test1 b/fuzzing/inputs/test1 index eacfbf5e605778dff836a3ae11cadfccb1c0d857..6a0c0d7c596034f729dc2acc2e4262b2396750c8 100644 --- a/fuzzing/inputs/test1 +++ b/fuzzing/inputs/test1 @@ -1,4 +1,4 @@ -{ +bf{ "glossary": { "title": "example glossary", "GlossDiv": { diff --git a/fuzzing/inputs/test10 b/fuzzing/inputs/test10 index d19eb8b5d2384ef7576fb46509ddc1db78a08b45..01e9a82f67d09b2a5e5bff75bc1f00fdf8ef97ce 100644 --- a/fuzzing/inputs/test10 +++ b/fuzzing/inputs/test10 @@ -1 +1 @@ -["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"] +bf["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"] diff --git a/fuzzing/inputs/test11 b/fuzzing/inputs/test11 index eaf43e6efc271fb42b12084946b691f85f195de5..818c6e0f286296dd6b2d897c0985797114717593 100644 --- a/fuzzing/inputs/test11 +++ b/fuzzing/inputs/test11 @@ -1,4 +1,4 @@ -{ +bf{ "name": "Jack (\"Bee\") Nimble", "format": {"type": "rect", "width": 1920, diff --git a/fuzzing/inputs/test2 b/fuzzing/inputs/test2 index 5600991a4c7a02a9365bbc8248806fd11c3d197b..3fdf8cb78682e4e8d967c843103ef073d04b8af2 100644 --- a/fuzzing/inputs/test2 +++ b/fuzzing/inputs/test2 @@ -1,4 +1,4 @@ -{"menu": { +bf{"menu": { "id": "file", "value": "File", "popup": { diff --git a/fuzzing/inputs/test3 b/fuzzing/inputs/test3 index 5662b3774e83cf212359c9838c2326dc7b309586..7143163ba2dfa8ee539b534aa84f9762da9bd887 100644 --- a/fuzzing/inputs/test3 +++ b/fuzzing/inputs/test3 @@ -1,4 +1,4 @@ -{"widget": { +bf{"widget": { "debug": "on", "window": { "title": "Sample Konfabulator Widget", @@ -23,4 +23,4 @@ "alignment": "center", "onMouseUp": "sun1.opacity = (sun1.opacity / 100) * 90;" } -}} \ No newline at end of file +}} diff --git a/fuzzing/inputs/test3.bu b/fuzzing/inputs/test3.bu new file mode 100644 index 0000000000000000000000000000000000000000..6fc93d3cfc788d2e299c99ee8babf589451cb84f --- /dev/null +++ b/fuzzing/inputs/test3.bu @@ -0,0 +1,26 @@ +bu{"widget": { + "debug": "on", + "window": { + "title": "Sample Konfabulator Widget", + "name": "main_window", + "width": 500, + "height": 500 + }, + "image": { + "src": "Images/Sun.png", + "name": "sun1", + "hOffset": 250, + "vOffset": 250, + "alignment": "center" + }, + "text": { + "data": "Click Here", + "size": 36, + "style": "bold", + "name": "text1", + "hOffset": 250, + "vOffset": 100, + "alignment": "center", + "onMouseUp": "sun1.opacity = (sun1.opacity / 100) * 90;" + } +}} diff --git a/fuzzing/inputs/test3.uf b/fuzzing/inputs/test3.uf new file mode 100644 index 0000000000000000000000000000000000000000..d48df612644fca0a5ac7ab2b37017be35c2e3d38 --- /dev/null +++ b/fuzzing/inputs/test3.uf @@ -0,0 +1,26 @@ +uf{"widget": { + "debug": "on", + "window": { + "title": "Sample Konfabulator Widget", + "name": "main_window", + "width": 500, + "height": 500 + }, + "image": { + "src": "Images/Sun.png", + "name": "sun1", + "hOffset": 250, + "vOffset": 250, + "alignment": "center" + }, + "text": { + "data": "Click Here", + "size": 36, + "style": "bold", + "name": "text1", + "hOffset": 250, + "vOffset": 100, + "alignment": "center", + "onMouseUp": "sun1.opacity = (sun1.opacity / 100) * 90;" + } +}} diff --git a/fuzzing/inputs/test3.uu b/fuzzing/inputs/test3.uu new file mode 100644 index 0000000000000000000000000000000000000000..ad6ae54102c43f45bd0c8e66d5c1071bd492ff5a --- /dev/null +++ b/fuzzing/inputs/test3.uu @@ -0,0 +1,26 @@ +uu{"widget": { + "debug": "on", + "window": { + "title": "Sample Konfabulator Widget", + "name": "main_window", + "width": 500, + "height": 500 + }, + "image": { + "src": "Images/Sun.png", + "name": "sun1", + "hOffset": 250, + "vOffset": 250, + "alignment": "center" + }, + "text": { + "data": "Click Here", + "size": 36, + "style": "bold", + "name": "text1", + "hOffset": 250, + "vOffset": 100, + "alignment": "center", + "onMouseUp": "sun1.opacity = (sun1.opacity / 100) * 90;" + } +}} diff --git a/fuzzing/inputs/test4 b/fuzzing/inputs/test4 index d540b57f0df6834de5d58a5ae874c3661e50e51f..e24ae9b3d704e330d5c45d65741da4e931b5c838 100644 --- a/fuzzing/inputs/test4 +++ b/fuzzing/inputs/test4 @@ -1,4 +1,4 @@ -{"web-app": { +bf{"web-app": { "servlet": [ { "servlet-name": "cofaxCDS", @@ -85,4 +85,4 @@ "taglib": { "taglib-uri": "cofax.tld", - "taglib-location": "/WEB-INF/tlds/cofax.tld"}}} \ No newline at end of file + "taglib-location": "/WEB-INF/tlds/cofax.tld"}}} diff --git a/fuzzing/inputs/test5 b/fuzzing/inputs/test5 index 49980ca25bcc4b9e11efb75946bc15febb4ec352..f6cc84e131f9022bcc017b6cfa8ea65a64b50382 100644 --- a/fuzzing/inputs/test5 +++ b/fuzzing/inputs/test5 @@ -1,4 +1,4 @@ -{"menu": { +bf{"menu": { "header": "SVG Viewer", "items": [ {"id": "Open"}, diff --git a/fuzzing/inputs/test6 b/fuzzing/inputs/test6 index d5cb28f6703e2348628cca50f79db13ee3f13f83..af279752e8c4ee6a5e172057f27fe18ca5453200 100644 --- a/fuzzing/inputs/test6 +++ b/fuzzing/inputs/test6 @@ -1,4 +1,4 @@ - +bf @@ -13,4 +13,4 @@

Application Error

- \ No newline at end of file + diff --git a/fuzzing/inputs/test7 b/fuzzing/inputs/test7 index 330853664c43709710fdb4b7222b62823691886a..4a3c0b7a1be7526f5e51fc3bcb7e0d2bcc475c31 100644 --- a/fuzzing/inputs/test7 +++ b/fuzzing/inputs/test7 @@ -1,4 +1,4 @@ -[ +bf[ { "precision": "zip", "Latitude": 37.7668, diff --git a/fuzzing/inputs/test8 b/fuzzing/inputs/test8 index 4b1f5b97c24ddb4e52d678d80877310edefe5cae..3ffe570ce1fb30341a9c312211df58b000b0032d 100644 --- a/fuzzing/inputs/test8 +++ b/fuzzing/inputs/test8 @@ -1,4 +1,4 @@ -{ +bf{ "Image": { "Width": 800, "Height": 600, diff --git a/fuzzing/inputs/test9 b/fuzzing/inputs/test9 index 2a939b96c841ad320f4033342aa4ea4cb89a582a..28c9033ad64858ec33bc4695134e876c769a1f25 100644 --- a/fuzzing/inputs/test9 +++ b/fuzzing/inputs/test9 @@ -1,4 +1,4 @@ -[ +bf[ [0, -1, 0], [1, 0, 0], [0, 0, 1]