subprocess return None what does that mean for my fuzzer

300 Views Asked by At

For school I have to make a fuzzer, I use Charle Miller to fuze pdf files. I want to check to amount of failure of an app. When I do

result = process.communicate()
    print(result)

it print (None,None) several times what does that mean?

1

There are 1 best solutions below

3
Nick T On

It means that when you created the subprocess.Popen object, you did not specify stdout=PIPE or stderr=PIPE.

Popen.communicate(input=None, timeout=None)

Interact with process: Send data to stdin. Read data from stdout and stderr [...]

communicate() returns a tuple (stdout_data, stderr_data). [...]

Note that if you want to send data to the process’s stdin, you need to create the Popen object with stdin=PIPE. Similarly, to get anything other than None in the result tuple, you need to give stdout=PIPE and/or stderr=PIPE [emph. added] too.

subprocess - Subprocess Management - Python 3 Documentation

For example:

import subprocess
apples_only = subprocess.Popen(
    ["grep", "apple"], 
    stdin=subprocess.PIPE, 
    stdout=subprocess.PIPE,
)
out, err = apples_only.communicate(b"pear\napple\nbanana\n")

print((out, err))
# (b'apple\n', None)  # did not say stderr=PIPE so it's None.