Skip to content

Commit

Permalink
pre-commit: add hooks forbid-tabs and remove-tabs
Browse files Browse the repository at this point in the history
The indentation settings have been taken from the `.editorconfig` file

https://github.com/Lucas-C/pre-commit-hooks
  • Loading branch information
jbampton committed Oct 26, 2022
1 parent 52a3dc2 commit aab7bc0
Show file tree
Hide file tree
Showing 5 changed files with 438 additions and 435 deletions.
13 changes: 8 additions & 5 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,14 @@ repos:
- id: fix-byte-order-marker
- id: mixed-line-ending
- id: trailing-whitespace
# - repo: git://github.com/Lucas-C/pre-commit-hooks
# rev: v1.1.9
# hooks:
# - id: forbid-tabs
# - id: remove-tabs
- repo: https://github.com/Lucas-C/pre-commit-hooks
rev: v1.3.1
hooks:
- id: forbid-tabs
files: \.(c|cc|C|cxx|cpp|gembox|gemspec|h|hh|H|hxx|hpp|inc|md|mdown|markdown|rake|rb|y|yaml|yml)$|^Rakefile$|^rakefile$
- id: remove-tabs
args: [--whitespaces-count, '2']
files: \.(c|cc|C|cxx|cpp|gembox|gemspec|h|hh|H|hxx|hpp|inc|md|mdown|markdown|rake|rb|y|yaml|yml)$|^Rakefile$|^rakefile$
- repo: https://github.com/codespell-project/codespell
rev: v2.2.1
hooks:
Expand Down
52 changes: 26 additions & 26 deletions oss-fuzz/mruby_proto_fuzzer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,33 +13,33 @@ using namespace ruby_fuzzer;
using namespace std;

int FuzzRB(const uint8_t *Data, size_t size) {
mrb_value v;
mrb_state *mrb = mrb_open();
if (!mrb)
return 0;

char *code = (char *)malloc(size+1);
if (!code)
return 0;
memcpy(code, Data, size);
code[size] = '\0';

if (const char *dump_path = getenv("PROTO_FUZZER_DUMP_PATH")) {
// With libFuzzer binary run this to generate an RB file x.rb:
// PROTO_FUZZER_DUMP_PATH=x.rb ./a.out proto-input
std::ofstream of(dump_path);
of.write(code, size);
}
std::cout << "\n\n############\n" << code << "\n############\n\n";
v = mrb_load_string(mrb, code);
mrb_close(mrb);

free(code);
return 0;
mrb_value v;
mrb_state *mrb = mrb_open();
if (!mrb)
return 0;

char *code = (char *)malloc(size+1);
if (!code)
return 0;
memcpy(code, Data, size);
code[size] = '\0';

if (const char *dump_path = getenv("PROTO_FUZZER_DUMP_PATH")) {
// With libFuzzer binary run this to generate an RB file x.rb:
// PROTO_FUZZER_DUMP_PATH=x.rb ./a.out proto-input
std::ofstream of(dump_path);
of.write(code, size);
}
std::cout << "\n\n############\n" << code << "\n############\n\n";
v = mrb_load_string(mrb, code);
mrb_close(mrb);

free(code);
return 0;
}

DEFINE_PROTO_FUZZER(const Function &function) {
protoConverter converter;
auto s = converter.FunctionToString(function);
(void)FuzzRB((const uint8_t*)s.data(), s.size());
protoConverter converter;
auto s = converter.FunctionToString(function);
(void)FuzzRB((const uint8_t*)s.data(), s.size());
}
Loading

0 comments on commit aab7bc0

Please sign in to comment.