<commit_before># afl-fuzz fixup shim

This is a skeleton to fixup tests for afl-fuzz >= 1.52. I've used a Go fixer,
but it should work for any language.

The way everything works:

afl-fuzz will load a fixup library as a .so if you pass it the
`AFL_POST_LIBRARY` environment variable. It will then call afl_postprocess
once per test. If you want to write your fixup code in C then rejoice - you're
done! Just modify the afl example in experimental/post_library. If not, read
on.

The C code in ext/ builds a shim .so that will write each test received from
afl to a long-running unix socket using DJB netstrings, read a response and
return that to afl. It is configured via the `AFL_FIX_SOCK` environment
variable.

More about netstrings: http://cr.yp.to/proto/netstrings.txt

This architecture should allow you to write fixers in any language that can
talk to unix sockets, which should be more or less any language at all.

Caveats:

- Start your fix server BEFORE you start afl. The shim will die if it can't
  connect.
- Don't be slow. This is on the critical path.
- Don't screw up. If you send the shim a broken netstring it will exit() and
  take afl with it.
- Don't use this at all. It's a bad approach and will do more harm than good
  in almost all cases.

Benchmark for a very simple string substitution fixer:
```
$ go test -bench=.
PASS
BenchmarkFixup	  100000	     22149 ns/op
ok  	github.com/bnagy/aflfix	2.507s
```
(this excludes the C side overhead)

## Bugs

This was not written in the anticipation of anyone else using it.

## Contributing

Fork & pullreq

## License

BSD Style, See LICENSE file for details
(c) <NAME>, 2015
<commit_msg>minor formatting<commit_after># afl-fuzz fixup shim

## General Information

This is a skeleton to fixup tests for afl-fuzz >= 1.52. I've used a Go fixer,
but it should work for any language.

### The way everything works:

afl-fuzz will load a fixup library as a .so if you pass it the
`AFL_POST_LIBRARY` environment variable. It will then call afl_postprocess
once per test. If you want to write your fixup code in C then rejoice - you're
done! Just modify the afl example in experimental/post_library. If not, read
on.

The C code in ext/ builds a shim .so that will write each test received from
afl to a long-running unix socket using DJB netstrings, read a response and
return that to afl. It is configured via the `AFL_FIX_SOCK` environment
variable.

More about netstrings: http://cr.yp.to/proto/netstrings.txt

This architecture should allow you to write fixers in any language that can
talk to unix sockets, which should be more or less any language at all.

### Caveats:

- Start your fix server BEFORE you start afl. The shim will die if it can't
  connect.
- Don't be slow. This is on the critical path.
- Don't screw up. If you send the shim a broken netstring it will exit() and
  take afl with it.
- Don't use this at all. It's a bad approach and will do more harm than good
  in almost all cases.

Benchmark for the Go side of a very simple string substitution fixer:
```
$ go test -bench=.
PASS
BenchmarkFixup	  100000	     22149 ns/op
ok  	github.com/bnagy/aflfix	2.507s
```

## Bugs

This was not written in the anticipation of anyone else using it.

## Contributing

Fork & pullreq

## License

BSD Style, See LICENSE file for details
(c) <NAME>, 2015

{'fraction_non_alphanumeric': 0.06062424969987995, 'fraction_numerical': 0.013205282112845138, 'mean_word_length': 3.6163434903047094, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4056079', 'n_tokens_mistral': 1081, 'n_tokens_neox': 1014, 'n_words': 539}