MCPcopy Create free account
hub / github.com/F-Stack/f-stack / stringmatchlen_fuzz_test

Function stringmatchlen_fuzz_test

app/redis-6.2.6/src/util.c:173–186  ·  view source on GitHub ↗

Fuzz stringmatchlen() trying to crash it with bad input. */

Source from the content-addressed store, hash-verified

171
172/* Fuzz stringmatchlen() trying to crash it with bad input. */
173int stringmatchlen_fuzz_test(void) {
174 char str[32];
175 char pat[32];
176 int cycles = 10000000;
177 int total_matches = 0;
178 while(cycles--) {
179 int strlen = rand() % sizeof(str);
180 int patlen = rand() % sizeof(pat);
181 for (int j = 0; j < strlen; j++) str[j] = rand() % 128;
182 for (int j = 0; j < patlen; j++) pat[j] = rand() % 128;
183 total_matches += stringmatchlen(pat, patlen, str, strlen, 0);
184 }
185 return total_matches;
186}
187
188/* Convert a string representing an amount of memory into the number of
189 * bytes, so for instance memtoll("1Gb") will return 1073741824 that is

Callers 1

debugCommandFunction · 0.85

Calls 1

stringmatchlenFunction · 0.85

Tested by

no test coverage detected