Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
ftheirs committed Jun 11, 2024
1 parent 2e2f300 commit a16c46d
Show file tree
Hide file tree
Showing 13 changed files with 38 additions and 6 deletions.
7 changes: 6 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ cmake_policy(SET CMP0025 NEW)
cmake_policy(SET CMP0144 NEW)

set(HUNTER_STATUS_DEBUG ON)
set(HUNTER_TLS_VERIFY OFF)
set(HUNTER_TLS_VERIFY ON)

enable_testing()

Expand Down Expand Up @@ -65,6 +65,11 @@ if(ENABLE_FUZZING)
SET(ENABLE_SANITIZERS ON CACHE BOOL "Sanitizer automatically enabled" FORCE)
SET(CMAKE_BUILD_TYPE Debug)

add_definitions(-DENABLE_COVERAGE=1)
string(APPEND CMAKE_C_FLAGS " -fprofile-arcs -ftest-coverage")
string(APPEND CMAKE_CXX_FLAGS " -fprofile-arcs -ftest-coverage")
string(APPEND CMAKE_LINKER_FLAGS " -fprofile-arcs -ftest-coverage")

if (DEFINED ENV{FUZZ_LOGGING})
add_definitions(-DFUZZING_LOGGING)
message(FATAL_ERROR "Fuzz logging enabled")
Expand Down
2 changes: 1 addition & 1 deletion app/Makefile.version
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# This is the `transaction_version` field of `Runtime`
APPVERSION_M=26
# This is the `spec_version` field of `Runtime`
APPVERSION_N=1002005
APPVERSION_N=12005
# This is the patch version of this release
APPVERSION_P=0
4 changes: 3 additions & 1 deletion app/src/parser_impl_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
#include "substrate_types.h"
#include "substrate_dispatch.h"

#define SUPPORTED_SPEC_VERSION_V26 1002005

parser_error_t parser_init_context(parser_context_t *ctx,
const uint8_t *buffer,
uint16_t bufferSize) {
Expand Down Expand Up @@ -352,7 +354,7 @@ static parser_error_t _checkVersionsV26(parser_context_t *c) {
transactionVersion += (uint32_t) p[3] << 24u;

if (transactionVersion != (SUPPORTED_TX_VERSION_CURRENT) ||
specVersion != SUPPORTED_SPEC_VERSION) {
specVersion != SUPPORTED_SPEC_VERSION_V26) {
return parser_tx_version_not_supported;
}

Expand Down
2 changes: 1 addition & 1 deletion app/src/substrate/substrate_types.c
Original file line number Diff line number Diff line change
Expand Up @@ -4545,7 +4545,7 @@ parser_error_t _toStringPercent(
uint8_t pageIdx,
uint8_t* pageCount)
{
char bufferUI[50];
char bufferUI[60];
char bufferRatio[50];

uint64_to_str(bufferRatio, sizeof(bufferRatio), v->value);
Expand Down
23 changes: 23 additions & 0 deletions fuzz/generateInitialCorpus.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import json
import os

def extract_blobs(json_file, initial_corpus_dir):
# Load the JSON file containing the test cases
with open(json_file, 'r') as file:
test_cases = json.load(file)

# Write the 'blob' field of each test case to a separate file in the initial_corpus_dir
for i, test_case in enumerate(test_cases):
blob_content = test_case.get('blob', '') # Get the 'blob' field or default to empty string if not found
if blob_content: # Only write out if blob_content is not empty
case_path = os.path.join(initial_corpus_dir, f'blob_{i}.txt')
with open(case_path, 'w') as case_file:
case_file.write(blob_content)

# Ensure the initial_corpus_dir is created
initial_corpus_dir = os.path.join('fuzz', 'corpora', 'initial_corpus')
os.makedirs(initial_corpus_dir, exist_ok=True)

# Process both current and previous test cases
extract_blobs('tests/testcases_current.json', initial_corpus_dir)
extract_blobs('tests/testcases_previous.json', initial_corpus_dir)
6 changes: 4 additions & 2 deletions fuzz/run-fuzzers.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,12 @@

artifact_dir = os.path.join('fuzz', 'corpora', f'{fuzzer}-artifacts')
corpus_dir = os.path.join('fuzz', 'corpora', f'{fuzzer}')
fuzz_path = os.path.join(f'build/bin/fuzz-{fuzzer}')
fuzz_path = os.path.join(f'build/fuzz-{fuzzer}')
initial_corpus_dir = os.path.join('fuzz', 'corpora', 'initial_corpus')

os.makedirs(artifact_dir, exist_ok=True)
os.makedirs(corpus_dir, exist_ok=True)
os.makedirs(initial_corpus_dir, exist_ok=True)

env = os.environ.copy()
env['ASAN_OPTIONS'] = 'halt_on_error=1:print_stacktrace=1'
Expand All @@ -34,6 +36,6 @@
f'-max_len={max_len}',
f'-mutate_depth={MUTATE_DEPTH}',
f'-artifact_prefix={artifact_dir}/',
corpus_dir]
corpus_dir, initial_corpus_dir]
print(' '.join(shlex.quote(c) for c in cmd))
subprocess.call(cmd, env=env)
Binary file modified tests_zemu/snapshots/s-mainmenu/00004.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests_zemu/snapshots/s-mainmenu/00010.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests_zemu/snapshots/sp-mainmenu/00004.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests_zemu/snapshots/sp-mainmenu/00010.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests_zemu/snapshots/st-mainmenu/00001.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests_zemu/snapshots/x-mainmenu/00004.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests_zemu/snapshots/x-mainmenu/00010.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit a16c46d

Please sign in to comment.