MozillaSecurity / funfuzz

A collection of fuzzers in a harness for testing the SpiderMonkey JavaScript engine.
Mozilla Public License 2.0
631 stars 115 forks source link

[funfuzz] TypeError thrown when file_contains_str is run after move to Python 3.6+ #220

Closed nth10sd closed 5 years ago

nth10sd commented 5 years ago
Traceback (most recent call last):
  File "/usr/local/Cellar/python/3.7.2_1/Frameworks/Python.framework/Versions/3.7/lib/python3.7/multiprocessing/process.py", line 297, in _bootstrap
    self.run()
  File "/usr/local/Cellar/python/3.7.2_1/Frameworks/Python.framework/Versions/3.7/lib/python3.7/multiprocessing/process.py", line 99, in run
    self._target(*self._args, **self._kwargs)
  File "/Users/fuzz8/trees/venv-py37-fm/lib/python3.7/site-packages/funfuzz/util/fork_join.py", line 67, in redirectOutputAndCallFun
    fun(*(someArgs + (i,)))
  File "/Users/fuzz8/trees/venv-py37-fm/lib/python3.7/site-packages/funfuzz/bot.py", line 216, in loopFuzzingAndReduction
    loop.many_timed_runs(options.targetTime, tempDir, buildInfo.mtrArgs, collector, False)
  File "/Users/fuzz8/trees/venv-py37-fm/lib/python3.7/site-packages/funfuzz/js/loop.py", line 206, in many_timed_runs
    options.build_options_str, target_time, js_interesting_opts, ccoverage)
  File "/Users/fuzz8/trees/venv-py37-fm/lib/python3.7/site-packages/funfuzz/js/compare_jit.py", line 76, in compare_jit
    itest, logPrefix, jsEngine, [], infilename, repo, build_options_str, targetTime, lev)
  File "/Users/fuzz8/trees/venv-py37-fm/lib/python3.7/site-packages/funfuzz/util/lithium_helpers.py", line 45, in pinpoint
    logPrefix, infilename, lithArgs, targetTime, suspiciousLevel)
  File "/Users/fuzz8/trees/venv-py37-fm/lib/python3.7/site-packages/funfuzz/util/lithium_helpers.py", line 225, in reduction_strat
    file_contains_str(str(infilename), "isAsmJSCompilationAvailable"))
  File "/Users/fuzz8/trees/venv-py37-fm/lib/python3.7/site-packages/lithium/interestingness/utils.py", line 60, in file_contains_str
    if line.find(regex) != -1:
TypeError: argument should be integer or bytes-like object, not 'str'

Turns out that since file_contains_str opens the file in rb mode, we should pass in bytes instead of a string...