Skip to content

Commit

Permalink
linux/process: Support reading empty values from /proc/pid/status
Browse files Browse the repository at this point in the history
The file /proc/<pid>/status provides information about a process in
the format 'key: value'. The parsing of this file failed if 'value'
was empty.

Add an dummy value that will be taken in case the real value from
the status file does not exist.

Additionally, update the log message from the parsing code to also
output the exception, if one is raised.

Related: cuckoosandbox#3035
  • Loading branch information
omeranson committed May 20, 2020
1 parent 8e472fc commit 1cf8c60
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions cuckoo/data/analyzer/linux/lib/api/process.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@ def get_parent_pid(self):
def get_proc_status(self):
try:
status = open("/proc/%u/status" % self.pid).readlines()
status_values = dict((i[0], i[1]) for i in [j.strip().split(None, 1) for j in status])
status_values = dict((i[0], i[1]) for i in [j.strip().split(None, 1) + [""] for j in status])
return status_values
except:
log.critical("could not get process status for pid %u", self.pid)
log.exception("could not get process status for pid %u", self.pid)
return {}

def execute(self, cmd):
Expand Down

0 comments on commit 1cf8c60

Please sign in to comment.