Fossil SCM
Extend the fuzzer to have the ability to run comment_print().
Commit
8639f9b2d52aa4c79b7ac5ee35f6160e76ef04ca6bfe011d8683d57c2fa30029
Parent
2aa79ed7521b6c6…
1 file changed
+12
-1
+12
-1
| --- src/fuzz.c | ||
| +++ src/fuzz.c | ||
| @@ -60,10 +60,11 @@ | ||
| 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 | 64 | #define FUZZ_WIKI2 3 /* FOSSIL_WIKI and FOSSIL_MARKDOWN */ |
| 65 | +#define FUZZ_COMFORMAT 4 /* comment_print() */ | |
| 65 | 66 | #endif |
| 66 | 67 | |
| 67 | 68 | /* The type of fuzzing to do */ |
| 68 | 69 | static int eFuzzType = FUZZ_WIKI; |
| 69 | 70 | |
| @@ -93,13 +94,20 @@ | ||
| 93 | 94 | blob_reset(&out); |
| 94 | 95 | markdown_to_html(&in, &title, &out); |
| 95 | 96 | blob_reset(&title); |
| 96 | 97 | break; |
| 97 | 98 | } |
| 98 | - case FUZZ_ARTIFACT: | |
| 99 | + case FUZZ_ARTIFACT: { | |
| 99 | 100 | fossil_fatal("FUZZ_ARTIFACT is not implemented."); |
| 100 | 101 | break; |
| 102 | + } | |
| 103 | + case FUZZ_COMFORMAT: { | |
| 104 | + if( nByte>=3 && aData[1]!=0 && memchr(&aData[1], 0, nByte-1)!=0 ){ | |
| 105 | + int flags = (int)aData[0]; | |
| 106 | + comment_print((const char*)&aData[1],0,15,80,flags); | |
| 107 | + } | |
| 108 | + } | |
| 101 | 109 | } |
| 102 | 110 | blob_reset(&in); |
| 103 | 111 | blob_reset(&out); |
| 104 | 112 | return 0; |
| 105 | 113 | } |
| @@ -116,10 +124,12 @@ | ||
| 116 | 124 | eFuzzType = FUZZ_WIKI; |
| 117 | 125 | }else if( fossil_strcmp(zType,"markdown")==0 ){ |
| 118 | 126 | eFuzzType = FUZZ_MARKDOWN; |
| 119 | 127 | }else if( fossil_strcmp(zType,"wiki2")==0 ){ |
| 120 | 128 | eFuzzType = FUZZ_WIKI2; |
| 129 | + }else if( fossil_strcmp(zType,"comformat")==0 ){ | |
| 130 | + eFuzzType = FUZZ_COMFORMAT; | |
| 121 | 131 | }else{ |
| 122 | 132 | fossil_fatal("unknown fuzz type: \"%s\"", zType); |
| 123 | 133 | } |
| 124 | 134 | } |
| 125 | 135 | |
| @@ -139,10 +149,11 @@ | ||
| 139 | 149 | ** |
| 140 | 150 | ** Usage: %fossil test-fuzz [-fuzztype TYPE] INPUTFILE... |
| 141 | 151 | ** |
| 142 | 152 | ** Run a fuzz test using INPUTFILE as the test data. TYPE can be one of: |
| 143 | 153 | ** |
| 154 | +** comformat Fuzz the comment_print() routine | |
| 144 | 155 | ** wiki Fuzz the Fossil-wiki translator |
| 145 | 156 | ** markdown Fuzz the markdown translator |
| 146 | 157 | ** artifact Fuzz the artifact parser |
| 147 | 158 | ** wiki2 Fuzz the Fossil-wiki and markdown translator |
| 148 | 159 | */ |
| 149 | 160 |
| --- src/fuzz.c | |
| +++ src/fuzz.c | |
| @@ -60,10 +60,11 @@ | |
| 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 | |
| @@ -93,13 +94,20 @@ | |
| 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 | } |
| @@ -116,10 +124,12 @@ | |
| 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 | |
| @@ -139,10 +149,11 @@ | |
| 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 |
| --- src/fuzz.c | |
| +++ src/fuzz.c | |
| @@ -60,10 +60,11 @@ | |
| 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 | #define FUZZ_COMFORMAT 4 /* comment_print() */ |
| 66 | #endif |
| 67 | |
| 68 | /* The type of fuzzing to do */ |
| 69 | static int eFuzzType = FUZZ_WIKI; |
| 70 | |
| @@ -93,13 +94,20 @@ | |
| 94 | blob_reset(&out); |
| 95 | markdown_to_html(&in, &title, &out); |
| 96 | blob_reset(&title); |
| 97 | break; |
| 98 | } |
| 99 | case FUZZ_ARTIFACT: { |
| 100 | fossil_fatal("FUZZ_ARTIFACT is not implemented."); |
| 101 | break; |
| 102 | } |
| 103 | case FUZZ_COMFORMAT: { |
| 104 | if( nByte>=3 && aData[1]!=0 && memchr(&aData[1], 0, nByte-1)!=0 ){ |
| 105 | int flags = (int)aData[0]; |
| 106 | comment_print((const char*)&aData[1],0,15,80,flags); |
| 107 | } |
| 108 | } |
| 109 | } |
| 110 | blob_reset(&in); |
| 111 | blob_reset(&out); |
| 112 | return 0; |
| 113 | } |
| @@ -116,10 +124,12 @@ | |
| 124 | eFuzzType = FUZZ_WIKI; |
| 125 | }else if( fossil_strcmp(zType,"markdown")==0 ){ |
| 126 | eFuzzType = FUZZ_MARKDOWN; |
| 127 | }else if( fossil_strcmp(zType,"wiki2")==0 ){ |
| 128 | eFuzzType = FUZZ_WIKI2; |
| 129 | }else if( fossil_strcmp(zType,"comformat")==0 ){ |
| 130 | eFuzzType = FUZZ_COMFORMAT; |
| 131 | }else{ |
| 132 | fossil_fatal("unknown fuzz type: \"%s\"", zType); |
| 133 | } |
| 134 | } |
| 135 | |
| @@ -139,10 +149,11 @@ | |
| 149 | ** |
| 150 | ** Usage: %fossil test-fuzz [-fuzztype TYPE] INPUTFILE... |
| 151 | ** |
| 152 | ** Run a fuzz test using INPUTFILE as the test data. TYPE can be one of: |
| 153 | ** |
| 154 | ** comformat Fuzz the comment_print() routine |
| 155 | ** wiki Fuzz the Fossil-wiki translator |
| 156 | ** markdown Fuzz the markdown translator |
| 157 | ** artifact Fuzz the artifact parser |
| 158 | ** wiki2 Fuzz the Fossil-wiki and markdown translator |
| 159 | */ |
| 160 |