Fossil SCM
Correct fuzz.c to honor --fuzztype markdown and add --fuzztype wiki2 which works like its previous --fuzztype wiki behavior, sending all inputs through both the fossil-wiki and markdown translators. Added a fatal error for --fuzztype artifact, as that tester is not implemented.
Commit
8d4c4792080ad0e9fcb0e3573cf8cdaaca0f35a3960fd086bd7fe1c8547541ef
Parent
1bf6686e76252ef…
1 file changed
+20
-1
+20
-1
| --- src/fuzz.c | ||
| +++ src/fuzz.c | ||
| @@ -59,10 +59,11 @@ | ||
| 59 | 59 | ** Type of fuzzing: |
| 60 | 60 | */ |
| 61 | 61 | #define FUZZ_WIKI 0 /* The Fossil-Wiki formatter */ |
| 62 | 62 | #define FUZZ_MARKDOWN 1 /* The Markdown formatter */ |
| 63 | 63 | #define FUZZ_ARTIFACT 2 /* Fuzz the artifact parser */ |
| 64 | +#define FUZZ_WIKI2 3 /* FOSSIL_WIKI and FOSSIL_MARKDOWN */ | |
| 64 | 65 | #endif |
| 65 | 66 | |
| 66 | 67 | /* The type of fuzzing to do */ |
| 67 | 68 | static int eFuzzType = FUZZ_WIKI; |
| 68 | 69 | |
| @@ -73,17 +74,32 @@ | ||
| 73 | 74 | blob_init(&in, 0, 0); |
| 74 | 75 | blob_append(&in, (char*)aData, (int)nByte); |
| 75 | 76 | blob_zero(&out); |
| 76 | 77 | switch( eFuzzType ){ |
| 77 | 78 | case FUZZ_WIKI: { |
| 79 | + wiki_convert(&in, &out, 0); | |
| 80 | + blob_reset(&out); | |
| 81 | + break; | |
| 82 | + } | |
| 83 | + case FUZZ_MARKDOWN: { | |
| 84 | + Blob title = BLOB_INITIALIZER; | |
| 85 | + blob_reset(&out); | |
| 86 | + markdown_to_html(&in, &title, &out); | |
| 87 | + blob_reset(&title); | |
| 88 | + break; | |
| 89 | + } | |
| 90 | + case FUZZ_WIKI2: { | |
| 78 | 91 | Blob title = BLOB_INITIALIZER; |
| 79 | 92 | wiki_convert(&in, &out, 0); |
| 80 | 93 | blob_reset(&out); |
| 81 | 94 | markdown_to_html(&in, &title, &out); |
| 82 | 95 | blob_reset(&title); |
| 83 | 96 | break; |
| 84 | 97 | } |
| 98 | + case FUZZ_ARTIFACT: | |
| 99 | + fossil_fatal("FUZZ_ARTIFACT is not implemented."); | |
| 100 | + break; | |
| 85 | 101 | } |
| 86 | 102 | blob_reset(&in); |
| 87 | 103 | blob_reset(&out); |
| 88 | 104 | return 0; |
| 89 | 105 | } |
| @@ -98,10 +114,12 @@ | ||
| 98 | 114 | zType = find_option("fuzztype",0,1); |
| 99 | 115 | if( zType==0 || fossil_strcmp(zType,"wiki")==0 ){ |
| 100 | 116 | eFuzzType = FUZZ_WIKI; |
| 101 | 117 | }else if( fossil_strcmp(zType,"markdown")==0 ){ |
| 102 | 118 | eFuzzType = FUZZ_MARKDOWN; |
| 119 | + }else if( fossil_strcmp(zType,"wiki2")==0 ){ | |
| 120 | + eFuzzType = FUZZ_WIKI2; | |
| 103 | 121 | }else{ |
| 104 | 122 | fossil_fatal("unknown fuzz type: \"%s\"", zType); |
| 105 | 123 | } |
| 106 | 124 | } |
| 107 | 125 | |
| @@ -117,17 +135,18 @@ | ||
| 117 | 135 | } |
| 118 | 136 | |
| 119 | 137 | /* |
| 120 | 138 | ** COMMAND: test-fuzz |
| 121 | 139 | ** |
| 122 | -** Usage: %fossil test-fuzz [-type TYPE] INPUTFILE... | |
| 140 | +** Usage: %fossil test-fuzz [-fuzztype TYPE] INPUTFILE... | |
| 123 | 141 | ** |
| 124 | 142 | ** Run a fuzz test using INPUTFILE as the test data. TYPE can be one of: |
| 125 | 143 | ** |
| 126 | 144 | ** wiki Fuzz the Fossil-wiki translator |
| 127 | 145 | ** markdown Fuzz the markdown translator |
| 128 | 146 | ** artifact Fuzz the artifact parser |
| 147 | +** wiki2 Fuzz the Fossil-wiki and markdown translator | |
| 129 | 148 | */ |
| 130 | 149 | void fuzz_command(void){ |
| 131 | 150 | Blob in; |
| 132 | 151 | int i; |
| 133 | 152 | fuzzer_options(); |
| 134 | 153 |
| --- src/fuzz.c | |
| +++ src/fuzz.c | |
| @@ -59,10 +59,11 @@ | |
| 59 | ** Type of fuzzing: |
| 60 | */ |
| 61 | #define FUZZ_WIKI 0 /* The Fossil-Wiki formatter */ |
| 62 | #define FUZZ_MARKDOWN 1 /* The Markdown formatter */ |
| 63 | #define FUZZ_ARTIFACT 2 /* Fuzz the artifact parser */ |
| 64 | #endif |
| 65 | |
| 66 | /* The type of fuzzing to do */ |
| 67 | static int eFuzzType = FUZZ_WIKI; |
| 68 | |
| @@ -73,17 +74,32 @@ | |
| 73 | blob_init(&in, 0, 0); |
| 74 | blob_append(&in, (char*)aData, (int)nByte); |
| 75 | blob_zero(&out); |
| 76 | switch( eFuzzType ){ |
| 77 | case FUZZ_WIKI: { |
| 78 | Blob title = BLOB_INITIALIZER; |
| 79 | wiki_convert(&in, &out, 0); |
| 80 | blob_reset(&out); |
| 81 | markdown_to_html(&in, &title, &out); |
| 82 | blob_reset(&title); |
| 83 | break; |
| 84 | } |
| 85 | } |
| 86 | blob_reset(&in); |
| 87 | blob_reset(&out); |
| 88 | return 0; |
| 89 | } |
| @@ -98,10 +114,12 @@ | |
| 98 | zType = find_option("fuzztype",0,1); |
| 99 | if( zType==0 || fossil_strcmp(zType,"wiki")==0 ){ |
| 100 | eFuzzType = FUZZ_WIKI; |
| 101 | }else if( fossil_strcmp(zType,"markdown")==0 ){ |
| 102 | eFuzzType = FUZZ_MARKDOWN; |
| 103 | }else{ |
| 104 | fossil_fatal("unknown fuzz type: \"%s\"", zType); |
| 105 | } |
| 106 | } |
| 107 | |
| @@ -117,17 +135,18 @@ | |
| 117 | } |
| 118 | |
| 119 | /* |
| 120 | ** COMMAND: test-fuzz |
| 121 | ** |
| 122 | ** Usage: %fossil test-fuzz [-type TYPE] INPUTFILE... |
| 123 | ** |
| 124 | ** Run a fuzz test using INPUTFILE as the test data. TYPE can be one of: |
| 125 | ** |
| 126 | ** wiki Fuzz the Fossil-wiki translator |
| 127 | ** markdown Fuzz the markdown translator |
| 128 | ** artifact Fuzz the artifact parser |
| 129 | */ |
| 130 | void fuzz_command(void){ |
| 131 | Blob in; |
| 132 | int i; |
| 133 | fuzzer_options(); |
| 134 |
| --- src/fuzz.c | |
| +++ src/fuzz.c | |
| @@ -59,10 +59,11 @@ | |
| 59 | ** Type of fuzzing: |
| 60 | */ |
| 61 | #define FUZZ_WIKI 0 /* The Fossil-Wiki formatter */ |
| 62 | #define FUZZ_MARKDOWN 1 /* The Markdown formatter */ |
| 63 | #define FUZZ_ARTIFACT 2 /* Fuzz the artifact parser */ |
| 64 | #define FUZZ_WIKI2 3 /* FOSSIL_WIKI and FOSSIL_MARKDOWN */ |
| 65 | #endif |
| 66 | |
| 67 | /* The type of fuzzing to do */ |
| 68 | static int eFuzzType = FUZZ_WIKI; |
| 69 | |
| @@ -73,17 +74,32 @@ | |
| 74 | blob_init(&in, 0, 0); |
| 75 | blob_append(&in, (char*)aData, (int)nByte); |
| 76 | blob_zero(&out); |
| 77 | switch( eFuzzType ){ |
| 78 | case FUZZ_WIKI: { |
| 79 | wiki_convert(&in, &out, 0); |
| 80 | blob_reset(&out); |
| 81 | break; |
| 82 | } |
| 83 | case FUZZ_MARKDOWN: { |
| 84 | Blob title = BLOB_INITIALIZER; |
| 85 | blob_reset(&out); |
| 86 | markdown_to_html(&in, &title, &out); |
| 87 | blob_reset(&title); |
| 88 | break; |
| 89 | } |
| 90 | case FUZZ_WIKI2: { |
| 91 | Blob title = BLOB_INITIALIZER; |
| 92 | wiki_convert(&in, &out, 0); |
| 93 | blob_reset(&out); |
| 94 | markdown_to_html(&in, &title, &out); |
| 95 | blob_reset(&title); |
| 96 | break; |
| 97 | } |
| 98 | case FUZZ_ARTIFACT: |
| 99 | fossil_fatal("FUZZ_ARTIFACT is not implemented."); |
| 100 | break; |
| 101 | } |
| 102 | blob_reset(&in); |
| 103 | blob_reset(&out); |
| 104 | return 0; |
| 105 | } |
| @@ -98,10 +114,12 @@ | |
| 114 | zType = find_option("fuzztype",0,1); |
| 115 | if( zType==0 || fossil_strcmp(zType,"wiki")==0 ){ |
| 116 | eFuzzType = FUZZ_WIKI; |
| 117 | }else if( fossil_strcmp(zType,"markdown")==0 ){ |
| 118 | eFuzzType = FUZZ_MARKDOWN; |
| 119 | }else if( fossil_strcmp(zType,"wiki2")==0 ){ |
| 120 | eFuzzType = FUZZ_WIKI2; |
| 121 | }else{ |
| 122 | fossil_fatal("unknown fuzz type: \"%s\"", zType); |
| 123 | } |
| 124 | } |
| 125 | |
| @@ -117,17 +135,18 @@ | |
| 135 | } |
| 136 | |
| 137 | /* |
| 138 | ** COMMAND: test-fuzz |
| 139 | ** |
| 140 | ** Usage: %fossil test-fuzz [-fuzztype TYPE] INPUTFILE... |
| 141 | ** |
| 142 | ** Run a fuzz test using INPUTFILE as the test data. TYPE can be one of: |
| 143 | ** |
| 144 | ** wiki Fuzz the Fossil-wiki translator |
| 145 | ** markdown Fuzz the markdown translator |
| 146 | ** artifact Fuzz the artifact parser |
| 147 | ** wiki2 Fuzz the Fossil-wiki and markdown translator |
| 148 | */ |
| 149 | void fuzz_command(void){ |
| 150 | Blob in; |
| 151 | int i; |
| 152 | fuzzer_options(); |
| 153 |