提交 c5a09a32 编写于 作者: M Max Bruckner

fuzzing: Fuzz different print methods

This is achieved by encoding the type of function used in the first two
bytes.

First byte:
b: buffered

Second byte:
f: formatted
上级 4785070a
...@@ -101,20 +101,42 @@ int main(int argc, char** argv) ...@@ -101,20 +101,42 @@ int main(int argc, char** argv)
filename = argv[1]; filename = argv[1];
json = read_file(filename); json = read_file(filename);
if (json == NULL) if ((json == NULL) || (json[0] == '\0') || (json[1] == '\0'))
{ {
status = EXIT_FAILURE; status = EXIT_FAILURE;
goto cleanup; goto cleanup;
} }
item = cJSON_Parse(json); item = cJSON_Parse(json + 2);
if (item == NULL) if (item == NULL)
{ {
goto cleanup; goto cleanup;
} }
if ((argc == 3) && (strncmp(argv[2], "yes", 3) == 0)) if ((argc == 3) && (strncmp(argv[2], "yes", 3) == 0))
{
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); printed_json = cJSON_Print(item);
}
else
{
printed_json = cJSON_PrintUnformatted(item);
}
}
if (printed_json == NULL) if (printed_json == NULL)
{ {
status = EXIT_FAILURE; status = EXIT_FAILURE;
......
{ bf{
"glossary": { "glossary": {
"title": "example glossary", "title": "example glossary",
"GlossDiv": { "GlossDiv": {
......
["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"] bf["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"]
{ bf{
"name": "Jack (\"Bee\") Nimble", "name": "Jack (\"Bee\") Nimble",
"format": {"type": "rect", "format": {"type": "rect",
"width": 1920, "width": 1920,
......
{"menu": { bf{"menu": {
"id": "file", "id": "file",
"value": "File", "value": "File",
"popup": { "popup": {
......
{"widget": { bf{"widget": {
"debug": "on", "debug": "on",
"window": { "window": {
"title": "Sample Konfabulator Widget", "title": "Sample Konfabulator Widget",
......
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;"
}
}}
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;"
}
}}
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;"
}
}}
{"web-app": { bf{"web-app": {
"servlet": [ "servlet": [
{ {
"servlet-name": "cofaxCDS", "servlet-name": "cofaxCDS",
......
{"menu": { bf{"menu": {
"header": "SVG Viewer", "header": "SVG Viewer",
"items": [ "items": [
{"id": "Open"}, {"id": "Open"},
......
<!DOCTYPE html> bf<!DOCTYPE html>
<html> <html>
<head> <head>
<meta name="viewport" content="width=device-width, initial-scale=1"> <meta name="viewport" content="width=device-width, initial-scale=1">
......
[ bf[
{ {
"precision": "zip", "precision": "zip",
"Latitude": 37.7668, "Latitude": 37.7668,
......
{ bf{
"Image": { "Image": {
"Width": 800, "Width": 800,
"Height": 600, "Height": 600,
......
[ bf[
[0, -1, 0], [0, -1, 0],
[1, 0, 0], [1, 0, 0],
[0, 0, 1] [0, 0, 1]
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册