summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYifan Hong <elsk@google.com>2024-04-17 15:27:04 -0700
committerYifan Hong <elsk@google.com>2024-04-17 15:27:18 -0700
commit855c3c126d699ff40a87fe63c2281e55dcb8d427 (patch)
tree1905706b1c8fe048b4f4918aa287ff6e393e3a1b
parentb4b4d5beb00eb14b43778d71c250feea048ea950 (diff)
downloadGki-main.tar.gz
libkver: relax fuzzer check.HEADmastermain
For strings like 5.4-android1-00, the result of parsing it then reconverting it back to a string is 5.4-android1-0, so the equality check fails. Relax the check. Test: manual with the new corpus Fixes: 319755035 Change-Id: Ifbd006b071cabb939d86bd9f9b7a04f241ee670f
-rw-r--r--libkver/corpus/zero_zero1
-rw-r--r--libkver/fuzzer.cpp4
2 files changed, 3 insertions, 2 deletions
diff --git a/libkver/corpus/zero_zero b/libkver/corpus/zero_zero
new file mode 100644
index 0000000..8079d3a
--- /dev/null
+++ b/libkver/corpus/zero_zero
@@ -0,0 +1 @@
+5.4-android1-00 \ No newline at end of file
diff --git a/libkver/fuzzer.cpp b/libkver/fuzzer.cpp
index 406749a..da24ae0 100644
--- a/libkver/fuzzer.cpp
+++ b/libkver/fuzzer.cpp
@@ -31,12 +31,12 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
auto kmi_version = KmiVersion::Parse(string_data);
if (UNLIKELY(kmi_version.has_value())) {
- CHECK(string_data == kmi_version->string());
+ CHECK(!kmi_version->string().empty());
}
auto kernel_release = KernelRelease::Parse(string_data);
if (UNLIKELY(kernel_release.has_value())) {
- CHECK(string_data == kernel_release->string());
+ CHECK(!kernel_release->string().empty());
CHECK(!kernel_release->kmi_version().string().empty());
}