Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
mxvmem: make reading files more robust
Reading logfiles containing 'strange' bytes, would yield
errors like:

  "UnicodeDecodeError: 'utf-8' codec can't decode byte
   0xb3 in position 3221: invalid start byte"

Either switch to binary input, or escape the characters
in question. Here the latter was choosen.
  • Loading branch information
thomas committed Dec 6, 2022
1 parent 0cf0a26 commit 8d9c2f5
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions forensics/mxvmem
Expand Up @@ -110,7 +110,7 @@ class ProcBuffer():
def readfile(self, fn):
lines = 0
try:
f = open(fn)
f = open(fn, errors='backslashreplace')
except (FileNotFoundError, PermissionError): # do nothing
return 0
for line in f:
Expand Down Expand Up @@ -155,7 +155,7 @@ class ProcInfo(ProcInfoBase):
class ProcInfoSaved(ProcInfoBase): # aka forensics
''' Read from forensics file. '''
def __init__(self, logfile):
self.file = open(logfile)
self.file = open(logfile, errors='backslashreplace')
self.source = logfile

def __next__(self):
Expand Down

0 comments on commit 8d9c2f5

Please sign in to comment.