This is an automated email from the ASF dual-hosted git repository.
wasphin pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/brpc.git
The following commit(s) were added to refs/heads/master by this push:
new 3ee7ef6d fix(fuzzing): return 0 (not 1) from the size guard in every
harness (#3579)
3ee7ef6d is described below
commit 3ee7ef6dd7828ab39bed885a2bd8c7251a99111b
Author: li-lizhe <[email protected]>
AuthorDate: Mon Oct 5 23:15:39 2026 +0800
fix(fuzzing): return 0 (not 1) from the size guard in every harness (#3579)
LLVMFuzzerTestOneInput may only return 0 (input consumed) or -1 (input
rejected); libFuzzer asserts this after every call
(compiler-rt/lib/fuzzer/FuzzerLoop.cpp:622) and runs the empty input first,
so every harness here aborts an assert-enabled libFuzzer at startup.
Returning 0 keeps out-of-range inputs out of the corpus (the harness body is
still skipped) and matches the convention newer harnesses already use.
All 18 test/fuzzing/fuzz_*.cpp harnesses share the same guard.
Signed-off-by: li-lizhe <[email protected]>
---
test/fuzzing/fuzz_amf.cpp | 2 +-
test/fuzzing/fuzz_baidu_rpc.cpp | 2 +-
test/fuzzing/fuzz_butil.cpp | 2 +-
test/fuzzing/fuzz_couchbase.cpp | 2 +-
test/fuzzing/fuzz_esp.cpp | 2 +-
test/fuzzing/fuzz_hpack.cpp | 2 +-
test/fuzzing/fuzz_http.cpp | 2 +-
test/fuzzing/fuzz_http_parser.cpp | 2 +-
test/fuzzing/fuzz_hulu.cpp | 2 +-
test/fuzzing/fuzz_json.cpp | 2 +-
test/fuzzing/fuzz_memcache.cpp | 2 +-
test/fuzzing/fuzz_mongo.cpp | 2 +-
test/fuzzing/fuzz_redis.cpp | 2 +-
test/fuzzing/fuzz_shead.cpp | 2 +-
test/fuzzing/fuzz_sofa.cpp | 2 +-
test/fuzzing/fuzz_streaming.cpp | 2 +-
test/fuzzing/fuzz_thrift.cpp | 2 +-
test/fuzzing/fuzz_uri.cpp | 2 +-
18 files changed, 18 insertions(+), 18 deletions(-)
diff --git a/test/fuzzing/fuzz_amf.cpp b/test/fuzzing/fuzz_amf.cpp
index 60628ad1..c0d61017 100644
--- a/test/fuzzing/fuzz_amf.cpp
+++ b/test/fuzzing/fuzz_amf.cpp
@@ -25,7 +25,7 @@ extern "C" int
LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
{
if (size < kMinInputLength || size > kMaxInputLength){
- return 1;
+ return 0;
}
uint8_t mode = data[0] % 3;
diff --git a/test/fuzzing/fuzz_baidu_rpc.cpp b/test/fuzzing/fuzz_baidu_rpc.cpp
index 86074689..fcfa7a42 100644
--- a/test/fuzzing/fuzz_baidu_rpc.cpp
+++ b/test/fuzzing/fuzz_baidu_rpc.cpp
@@ -25,7 +25,7 @@ extern "C" int
LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
{
if (size < kMinInputLength || size > kMaxInputLength){
- return 1;
+ return 0;
}
std::string input(reinterpret_cast<const char*>(data), size);
diff --git a/test/fuzzing/fuzz_butil.cpp b/test/fuzzing/fuzz_butil.cpp
index 470d1e99..2f01a976 100644
--- a/test/fuzzing/fuzz_butil.cpp
+++ b/test/fuzzing/fuzz_butil.cpp
@@ -27,7 +27,7 @@ extern "C" int
LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
{
if (size < kMinInputLength || size > kMaxInputLength){
- return 1;
+ return 0;
}
std::string input(reinterpret_cast<const char*>(data), size);
diff --git a/test/fuzzing/fuzz_couchbase.cpp b/test/fuzzing/fuzz_couchbase.cpp
index f623c2ba..0663be68 100644
--- a/test/fuzzing/fuzz_couchbase.cpp
+++ b/test/fuzzing/fuzz_couchbase.cpp
@@ -25,7 +25,7 @@ extern "C" int
LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
{
if (size < kMinInputLength || size > kMaxInputLength){
- return 1;
+ return 0;
}
std::string input(reinterpret_cast<const char*>(data), size);
diff --git a/test/fuzzing/fuzz_esp.cpp b/test/fuzzing/fuzz_esp.cpp
index 9a26db86..905afeb0 100644
--- a/test/fuzzing/fuzz_esp.cpp
+++ b/test/fuzzing/fuzz_esp.cpp
@@ -25,7 +25,7 @@ extern "C" int
LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
{
if (size < kMinInputLength || size > kMaxInputLength){
- return 1;
+ return 0;
}
std::string input(reinterpret_cast<const char*>(data), size);
diff --git a/test/fuzzing/fuzz_hpack.cpp b/test/fuzzing/fuzz_hpack.cpp
index 0ee8131a..92033055 100644
--- a/test/fuzzing/fuzz_hpack.cpp
+++ b/test/fuzzing/fuzz_hpack.cpp
@@ -25,7 +25,7 @@ extern "C" int
LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
{
if (size < kMinInputLength || size > kMaxInputLength){
- return 1;
+ return 0;
}
std::string input(reinterpret_cast<const char*>(data), size);
diff --git a/test/fuzzing/fuzz_http.cpp b/test/fuzzing/fuzz_http.cpp
index c621d504..cedcae58 100644
--- a/test/fuzzing/fuzz_http.cpp
+++ b/test/fuzzing/fuzz_http.cpp
@@ -25,7 +25,7 @@ extern "C" int
LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
{
if (size < kMinInputLength || size > kMaxInputLength){
- return 1;
+ return 0;
}
std::string input(reinterpret_cast<const char*>(data), size);
diff --git a/test/fuzzing/fuzz_http_parser.cpp
b/test/fuzzing/fuzz_http_parser.cpp
index 0c6b792c..396b9e01 100644
--- a/test/fuzzing/fuzz_http_parser.cpp
+++ b/test/fuzzing/fuzz_http_parser.cpp
@@ -34,7 +34,7 @@ extern "C" int
LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
{
if (size < kMinInputLength || size > kMaxInputLength){
- return 1;
+ return 0;
}
// Use first byte to select mode
diff --git a/test/fuzzing/fuzz_hulu.cpp b/test/fuzzing/fuzz_hulu.cpp
index 74f9bec2..1f009d9b 100644
--- a/test/fuzzing/fuzz_hulu.cpp
+++ b/test/fuzzing/fuzz_hulu.cpp
@@ -25,7 +25,7 @@ extern "C" int
LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
{
if (size < kMinInputLength || size > kMaxInputLength){
- return 1;
+ return 0;
}
std::string input(reinterpret_cast<const char*>(data), size);
diff --git a/test/fuzzing/fuzz_json.cpp b/test/fuzzing/fuzz_json.cpp
index 3a0335f5..6252837d 100644
--- a/test/fuzzing/fuzz_json.cpp
+++ b/test/fuzzing/fuzz_json.cpp
@@ -25,7 +25,7 @@ extern "C" int
LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
{
if (size < kMinInputLength || size > kMaxInputLength){
- return 1;
+ return 0;
}
std::string error;
diff --git a/test/fuzzing/fuzz_memcache.cpp b/test/fuzzing/fuzz_memcache.cpp
index 52bfbfab..0cded3e9 100644
--- a/test/fuzzing/fuzz_memcache.cpp
+++ b/test/fuzzing/fuzz_memcache.cpp
@@ -25,7 +25,7 @@ extern "C" int
LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
{
if (size < kMinInputLength || size > kMaxInputLength){
- return 1;
+ return 0;
}
std::string input(reinterpret_cast<const char*>(data), size);
diff --git a/test/fuzzing/fuzz_mongo.cpp b/test/fuzzing/fuzz_mongo.cpp
index 18edc936..ea820759 100644
--- a/test/fuzzing/fuzz_mongo.cpp
+++ b/test/fuzzing/fuzz_mongo.cpp
@@ -25,7 +25,7 @@ extern "C" int
LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
{
if (size < kMinInputLength || size > kMaxInputLength){
- return 1;
+ return 0;
}
std::string input(reinterpret_cast<const char*>(data), size);
diff --git a/test/fuzzing/fuzz_redis.cpp b/test/fuzzing/fuzz_redis.cpp
index 6f4368dc..1932f614 100644
--- a/test/fuzzing/fuzz_redis.cpp
+++ b/test/fuzzing/fuzz_redis.cpp
@@ -25,7 +25,7 @@ extern "C" int
LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
{
if (size < kMinInputLength || size > kMaxInputLength){
- return 1;
+ return 0;
}
std::string input(reinterpret_cast<const char*>(data), size);
diff --git a/test/fuzzing/fuzz_shead.cpp b/test/fuzzing/fuzz_shead.cpp
index fd5d8c9b..05e5d455 100644
--- a/test/fuzzing/fuzz_shead.cpp
+++ b/test/fuzzing/fuzz_shead.cpp
@@ -26,7 +26,7 @@ extern "C" int
LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
{
if (size < kMinInputLength || size > kMaxInputLength){
- return 1;
+ return 0;
}
std::string input(reinterpret_cast<const char*>(data), size);
diff --git a/test/fuzzing/fuzz_sofa.cpp b/test/fuzzing/fuzz_sofa.cpp
index 84f39ec9..e0e29e06 100644
--- a/test/fuzzing/fuzz_sofa.cpp
+++ b/test/fuzzing/fuzz_sofa.cpp
@@ -27,7 +27,7 @@ extern "C" int
LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
{
if (size < kMinInputLength || size > kMaxInputLength){
- return 1;
+ return 0;
}
std::string input(reinterpret_cast<const char*>(data), size);
diff --git a/test/fuzzing/fuzz_streaming.cpp b/test/fuzzing/fuzz_streaming.cpp
index e8b79b8a..2e136e19 100644
--- a/test/fuzzing/fuzz_streaming.cpp
+++ b/test/fuzzing/fuzz_streaming.cpp
@@ -25,7 +25,7 @@ extern "C" int
LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
{
if (size < kMinInputLength || size > kMaxInputLength){
- return 1;
+ return 0;
}
std::string input(reinterpret_cast<const char*>(data), size);
diff --git a/test/fuzzing/fuzz_thrift.cpp b/test/fuzzing/fuzz_thrift.cpp
index c3928ffe..c310d1e0 100644
--- a/test/fuzzing/fuzz_thrift.cpp
+++ b/test/fuzzing/fuzz_thrift.cpp
@@ -24,7 +24,7 @@ extern "C" int
LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
{
if (size < kMinInputLength || size > kMaxInputLength){
- return 1;
+ return 0;
}
std::string input(reinterpret_cast<const char*>(data), size);
diff --git a/test/fuzzing/fuzz_uri.cpp b/test/fuzzing/fuzz_uri.cpp
index 3db1dec2..1be3bb83 100644
--- a/test/fuzzing/fuzz_uri.cpp
+++ b/test/fuzzing/fuzz_uri.cpp
@@ -25,7 +25,7 @@ extern "C" int
LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
{
if (size < kMinInputLength || size > kMaxInputLength){
- return 1;
+ return 0;
}
char *data_in = (char *)malloc(size + 1);
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]