Skip to content

Commit fa77f95

Browse files
author
MarcoFalke
committed
fuzz: Fix RPC internal bug detection
1 parent 577bd51 commit fa77f95

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

src/test/fuzz/rpc.cpp

+3-1
Original file line numberDiff line numberDiff line change
@@ -360,7 +360,9 @@ FUZZ_TARGET_INIT(rpc, initialize_rpc)
360360
rpc_testing_setup->CallRPC(rpc_command, arguments);
361361
} catch (const UniValue& json_rpc_error) {
362362
const std::string error_msg{find_value(json_rpc_error, "message").get_str()};
363-
if (error_msg.find("Internal bug detected") != std::string::npos) {
363+
// Once c++20 is allowed, starts_with can be used.
364+
// if (error_msg.starts_with("Internal bug detected")) {
365+
if (0 == error_msg.rfind("Internal bug detected", 0)) {
364366
// Only allow the intentional internal bug
365367
assert(error_msg.find("trigger_internal_bug") != std::string::npos);
366368
}

src/util/check.h

+3-3
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,11 @@ class NonFatalCheckError : public std::runtime_error
3333
do { \
3434
if (!(condition)) { \
3535
throw NonFatalCheckError( \
36-
strprintf("%s:%d (%s)\n" \
37-
"Internal bug detected: '%s'\n" \
36+
strprintf("Internal bug detected: '%s'\n" \
37+
"%s:%d (%s)\n" \
3838
"You may report this issue here: %s\n", \
39-
__FILE__, __LINE__, __func__, \
4039
(#condition), \
40+
__FILE__, __LINE__, __func__, \
4141
PACKAGE_BUGREPORT)); \
4242
} \
4343
} while (false)

0 commit comments

Comments
 (0)