mirror of
https://github.com/google/flatbuffers.git
synced 2026-06-22 15:28:52 +00:00
[idl_parser] Unify parsing of NaN values read from .fbs and .json files (#6296)
This commit unifies parsing of NaN values read from .fbs and .json files by converting them to unsigned NaN.
This commit is contained in:
@@ -139,6 +139,23 @@ target_link_libraries(monster_fuzzer PRIVATE flatbuffers_fuzzed)
|
||||
# Build debugger for weird cases found with fuzzer.
|
||||
if(BUILD_DEBUGGER)
|
||||
add_library(flatbuffers_nonfuzz STATIC ${FlatBuffers_Library_SRCS})
|
||||
target_compile_options(
|
||||
flatbuffers_nonfuzz
|
||||
PUBLIC
|
||||
$<$<BOOL:${USE_ASAN}>:
|
||||
-fsanitize=undefined,address
|
||||
>
|
||||
-fno-limit-debug-info
|
||||
)
|
||||
|
||||
target_link_libraries(
|
||||
flatbuffers_nonfuzz
|
||||
PUBLIC
|
||||
$<$<BOOL:${USE_ASAN}>:
|
||||
-fsanitize=undefined,address
|
||||
>
|
||||
)
|
||||
|
||||
target_compile_definitions(
|
||||
flatbuffers_nonfuzz
|
||||
PUBLIC
|
||||
@@ -147,6 +164,9 @@ if(BUILD_DEBUGGER)
|
||||
PRIVATE
|
||||
FLATBUFFERS_MAX_PARSING_DEPTH=${FLATBUFFERS_MAX_PARSING_DEPTH}
|
||||
)
|
||||
add_executable(scalar_debug flatbuffers_scalar_fuzzer.cc scalar_debug.cpp)
|
||||
add_executable(scalar_debug
|
||||
flatbuffers_scalar_fuzzer.cc
|
||||
scalar_debug.cpp
|
||||
)
|
||||
target_link_libraries(scalar_debug PRIVATE flatbuffers_nonfuzz)
|
||||
endif(BUILD_DEBUGGER)
|
||||
|
||||
@@ -288,7 +288,7 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
|
||||
}
|
||||
|
||||
// Parse original input as-is.
|
||||
auto orig_scalar = "{ \"Y\" : " + input + " }";
|
||||
auto orig_scalar = "{\"Y\" : " + input + "}";
|
||||
std::string orig_back;
|
||||
auto orig_done = Parse(parser, orig_scalar, &orig_back);
|
||||
|
||||
@@ -326,7 +326,7 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
|
||||
|
||||
// Test quoted version of the string
|
||||
if (!qouted_input.empty()) {
|
||||
auto fix_scalar = "{ \"Y\" : " + qouted_input + " }";
|
||||
auto fix_scalar = "{\"Y\" : " + qouted_input + "}";
|
||||
std::string fix_back;
|
||||
auto fix_done = Parse(parser, fix_scalar, &fix_back);
|
||||
|
||||
|
||||
@@ -23,6 +23,6 @@ int main(int argc, char *argv[]) {
|
||||
auto rc = LLVMFuzzerTestOneInput(
|
||||
reinterpret_cast<const uint8_t *>(crash_file_data.data()),
|
||||
crash_file_data.size());
|
||||
std::cout << "LLVMFuzzerTestOneInput finished with code " << rc;
|
||||
std::cout << "LLVMFuzzerTestOneInput finished with code " << rc << "\n\n";
|
||||
return rc;
|
||||
}
|
||||
|
||||
@@ -17,7 +17,11 @@
|
||||
"e"
|
||||
"f"
|
||||
"nan"
|
||||
"-nan"
|
||||
"+nan"
|
||||
"inf"
|
||||
"+inf"
|
||||
"-inf"
|
||||
"infinity"
|
||||
"+infinity"
|
||||
"-infinity"
|
||||
|
||||
Reference in New Issue
Block a user