Skip to content

Commit a906286

Browse files
committed
Automatically disable instrumentation when the -n option is provided.
1 parent c154551 commit a906286

File tree

3 files changed

+18
-11
lines changed

3 files changed

+18
-11
lines changed

afl.pyx

+8-10
Original file line numberDiff line numberDiff line change
@@ -75,16 +75,8 @@ def excepthook(tp, value, traceback):
7575
def start():
7676
cdef int use_forkserver = 1
7777
global afl_area
78-
afl_shm_id = os.getenv(SHM_ENV_VAR)
79-
if afl_shm_id is None:
80-
warnings.warn('no AFL environment')
81-
return
8278
if os.getenv('PYTHONHASHSEED', '') != '0':
8379
raise AflError('PYTHONHASHSEED != 0')
84-
afl_shm_id = int(afl_shm_id)
85-
afl_area = shmat(afl_shm_id, NULL, 0)
86-
if afl_area == <void*> -1:
87-
PyErr_SetFromErrno(OSError)
8880
try:
8981
os.write(FORKSRV_FD + 1, b'\0\0\0\0')
9082
except OSError as exc:
@@ -108,8 +100,14 @@ def start():
108100
os.close(FORKSRV_FD + 1)
109101
if except_signal_id != 0:
110102
sys.excepthook = excepthook
111-
if not os.getenv('PYTHON_AFL_DUMB'):
112-
sys.settrace(trace)
103+
afl_shm_id = os.getenv(SHM_ENV_VAR)
104+
if afl_shm_id is None:
105+
return
106+
afl_shm_id = int(afl_shm_id)
107+
afl_area = shmat(afl_shm_id, NULL, 0)
108+
if afl_area == <void*> -1:
109+
PyErr_SetFromErrno(OSError)
110+
sys.settrace(trace)
113111

114112
__all__ = ['start', 'AflError']
115113

doc/changelog

+8
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
python-afl (0.2) UNRELEASED; urgency=low
2+
3+
* Automatically disable instrumentation when the -n option is provided.
4+
Setting the PYTHON_AFL_DUMB environment variable is no longer needed.
5+
Thanks to Michal Zalewski for the hint how to implement this feature.
6+
7+
-- Jakub Wilk <jwilk@jwilk.net> Mon, 27 Apr 2015 18:24:22 +0200
8+
19
python-afl (0.1) unstable; urgency=low
210

311
* Initial release.

py-afl-fuzz

+2-1
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,10 @@
22
export PYTHONHASHSEED=0
33
export AFL_SKIP_CHECKS=1 # AFL << 1.20b
44
export AFL_SKIP_BIN_CHECK=1 # AFL >= 1.20b
5+
export AFL_DUMB_FORKSRV=1
56
if [ -n "$PYTHON_AFL_DUMB" ]
67
then
7-
export AFL_DUMB_FORKSRV=1
8+
printf '%s: $PYTHON_AFL_DUMB is deprecated; use -n instead\n' "$(basename "$0")" >&2
89
set -- -n "$@"
910
fi
1011
exec afl-fuzz "$@"

0 commit comments

Comments
 (0)