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.

stephan 2022-04-20 11:46 trunk
Commit 8d4c4792080ad0e9fcb0e3573cf8cdaaca0f35a3960fd086bd7fe1c8547541ef
1 file changed +20 -1
+20 -1
--- src/fuzz.c
+++ src/fuzz.c
@@ -59,10 +59,11 @@
5959
** Type of fuzzing:
6060
*/
6161
#define FUZZ_WIKI 0 /* The Fossil-Wiki formatter */
6262
#define FUZZ_MARKDOWN 1 /* The Markdown formatter */
6363
#define FUZZ_ARTIFACT 2 /* Fuzz the artifact parser */
64
+#define FUZZ_WIKI2 3 /* FOSSIL_WIKI and FOSSIL_MARKDOWN */
6465
#endif
6566
6667
/* The type of fuzzing to do */
6768
static int eFuzzType = FUZZ_WIKI;
6869
@@ -73,17 +74,32 @@
7374
blob_init(&in, 0, 0);
7475
blob_append(&in, (char*)aData, (int)nByte);
7576
blob_zero(&out);
7677
switch( eFuzzType ){
7778
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: {
7891
Blob title = BLOB_INITIALIZER;
7992
wiki_convert(&in, &out, 0);
8093
blob_reset(&out);
8194
markdown_to_html(&in, &title, &out);
8295
blob_reset(&title);
8396
break;
8497
}
98
+ case FUZZ_ARTIFACT:
99
+ fossil_fatal("FUZZ_ARTIFACT is not implemented.");
100
+ break;
85101
}
86102
blob_reset(&in);
87103
blob_reset(&out);
88104
return 0;
89105
}
@@ -98,10 +114,12 @@
98114
zType = find_option("fuzztype",0,1);
99115
if( zType==0 || fossil_strcmp(zType,"wiki")==0 ){
100116
eFuzzType = FUZZ_WIKI;
101117
}else if( fossil_strcmp(zType,"markdown")==0 ){
102118
eFuzzType = FUZZ_MARKDOWN;
119
+ }else if( fossil_strcmp(zType,"wiki2")==0 ){
120
+ eFuzzType = FUZZ_WIKI2;
103121
}else{
104122
fossil_fatal("unknown fuzz type: \"%s\"", zType);
105123
}
106124
}
107125
@@ -117,17 +135,18 @@
117135
}
118136
119137
/*
120138
** COMMAND: test-fuzz
121139
**
122
-** Usage: %fossil test-fuzz [-type TYPE] INPUTFILE...
140
+** Usage: %fossil test-fuzz [-fuzztype TYPE] INPUTFILE...
123141
**
124142
** Run a fuzz test using INPUTFILE as the test data. TYPE can be one of:
125143
**
126144
** wiki Fuzz the Fossil-wiki translator
127145
** markdown Fuzz the markdown translator
128146
** artifact Fuzz the artifact parser
147
+** wiki2 Fuzz the Fossil-wiki and markdown translator
129148
*/
130149
void fuzz_command(void){
131150
Blob in;
132151
int i;
133152
fuzzer_options();
134153
--- 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

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button