Skip to content

Commit

Permalink
tests: internal: fuzzers: cmetrics_fuzzer: extend
Browse files Browse the repository at this point in the history
Extend cmetrics_fuzzer so it reaches prometheus decoding logic as well.

Signed-off-by: David Korczynski <[email protected]>
  • Loading branch information
DavidKorczynski authored and edsiper committed Aug 8, 2023
1 parent e7f4da0 commit 3c7cfed
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion tests/internal/fuzzers/cmetrics_decode_fuzz.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
*/

#include <cmetrics/cmt_decode_opentelemetry.h>
#include <cmetrics/cmt_decode_prometheus.h>


int
Expand All @@ -34,7 +35,7 @@ LLVMFuzzerTestOneInput(const uint8_t * data, size_t size)
return 0;
}

decider = data[0] % 2;
decider = data[0] % 3;

/* Adjust data pointer since the first byte is used */
data += 1;
Expand All @@ -54,5 +55,15 @@ LLVMFuzzerTestOneInput(const uint8_t * data, size_t size)
cmt_destroy(cmt);
}
}
else if (decider == 2) {
if (size == 0) {
return 0;
}
struct cmt_decode_prometheus_parse_opts opts;
result = cmt_decode_prometheus_create(&cmt, data, size, &opts);
if (result == CMT_DECODE_PROMETHEUS_SUCCESS) {
cmt_decode_prometheus_destroy(cmt);
}
}
return 0;
}

0 comments on commit 3c7cfed

Please sign in to comment.