Fuzz stringmatchlen() trying to crash it with bad input. */
| 171 | |
| 172 | /* Fuzz stringmatchlen() trying to crash it with bad input. */ |
| 173 | int 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 |
no test coverage detected