Skip to content
Merged
Changes from 1 commit
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
8316e8d
Add basic fuzz tests for a few common builtin functions.
ssbr Jul 21, 2017
f47f875
Remove fuzzing of hash() per comment by kcc / oss-fuzz-team.
ssbr Jul 25, 2017
d112252
Move LLVMFuzzerTestOneInput into cpython and tweak how test discovery…
ssbr Jul 25, 2017
cb9cdc0
Move the fuzzer to C++ so that it builds.
ssbr Jul 25, 2017
7028614
Run the fuzz smoke tests on a little more input, just for kicks.
ssbr Jul 26, 2017
2b34f07
Make the _fuzz module optional.
ssbr Jul 26, 2017
f77be65
Actually run the fuzz tests...
ssbr Jul 26, 2017
778c827
Use unittest.main instead of test.support.
ssbr Jul 26, 2017
bc3d33f
Use C-style comments. (For porting to Python 2.7 and C89).
ssbr Jul 27, 2017
dee024f
Fix build break I accidentally introduced in f77be65.
ssbr Jul 27, 2017
9a00b23
Add a little detail on what the heck this stuff even is, in readme.
ssbr Jul 27, 2017
d542130
s/fuzzer.c/fuzzer.cpp/
ssbr Jul 27, 2017
9f16dd4
fuzzer.cpp -> fuzzer.c in faith that I can make it build.
ssbr Aug 3, 2017
aa6d784
Make _fuzz required, so that tests never fail on a successful build.
ssbr Aug 23, 2017
fa0af73
Fix the windows test failure by just not testing on windows. :)
ssbr Aug 23, 2017
4af5c11
NEWS entry thingermajig.
ssbr Aug 24, 2017
fb017ed
Blacklist test_fuzz from coverage tests. It seems to fail with a Memo…
ssbr Aug 24, 2017
c4eda5d
Remove outdated comment.
ssbr Aug 24, 2017
83967f9
Fix incorrect mod for base (should be % 37), and document why we're t…
ssbr Aug 25, 2017
52dccc2
Use more idiomatic NULL checks rather than PyErr_Occurred().
ssbr Aug 25, 2017
4327fd9
Attempt to explain a little more why these exist / what the relations…
ssbr Aug 25, 2017
6da8e97
Renamed _fuzz to _xxtestfuzz and cleanup.
gpshead Sep 6, 2017
43620ae
don't skip test_fuzz (besides, it was renamed)
gpshead Sep 6, 2017
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Use more idiomatic NULL checks rather than PyErr_Occurred().
  • Loading branch information
ssbr committed Aug 25, 2017
commit 52dccc288b5fd0e3e2d64f649b8471b4ae5e9b53
9 changes: 5 additions & 4 deletions Modules/_fuzz/fuzzer.c
Original file line number Diff line number Diff line change
Expand Up @@ -46,14 +46,14 @@ static int fuzz_builtin_int(const char* data, size_t size) {
}

PyObject* s = PyUnicode_FromStringAndSize(data, size);
if (PyErr_Occurred()) {
if (s == NULL) {
if (PyErr_ExceptionMatches(PyExc_UnicodeDecodeError)) {
PyErr_Clear();
}
return 0;
}
PyObject* l = PyLong_FromUnicodeObject(s, base);
if (PyErr_Occurred() && PyErr_ExceptionMatches(PyExc_ValueError)) {
if (l == NULL && PyErr_ExceptionMatches(PyExc_ValueError)) {
PyErr_Clear();
}
PyErr_Clear();
Expand All @@ -65,7 +65,7 @@ static int fuzz_builtin_int(const char* data, size_t size) {
/* Fuzz PyUnicode_FromStringAndSize as a proxy for unicode(str). */
static int fuzz_builtin_unicode(const char* data, size_t size) {
PyObject* s = PyUnicode_FromStringAndSize(data, size);
if (PyErr_Occurred() && PyErr_ExceptionMatches(PyExc_UnicodeDecodeError)) {
if (s == NULL && PyErr_ExceptionMatches(PyExc_UnicodeDecodeError)) {
PyErr_Clear();
}
Py_XDECREF(s);
Expand All @@ -76,7 +76,8 @@ static int fuzz_builtin_unicode(const char* data, size_t size) {
static int _run_fuzz(const uint8_t *data, size_t size, int(*fuzzer)(const char* , size_t)) {
int rv = fuzzer((const char*) data, size);
if (PyErr_Occurred()) {
/* Fuzz tests should handle expected errors for themselves. */
/* Fuzz tests should handle expected errors for themselves.
This is last-ditch check in case they didn't. */
PyErr_Print();
abort();
}
Expand Down