mirror of https://github.com/fail2ban/fail2ban
Check for unicode and encode before md5sum in filter
parent
c926c88ea1
commit
99c92a56ca
|
@ -526,6 +526,9 @@ class FileContainer:
|
|||
try:
|
||||
firstLine = handler.readline()
|
||||
# Computes the MD5 of the first line.
|
||||
if isinstance(firstLine, unicode):
|
||||
self.__hash = md5sum(firstLine.encode('utf-8')).digest()
|
||||
else:
|
||||
self.__hash = md5sum(firstLine).digest()
|
||||
# Start at the beginning of file if tail mode is off.
|
||||
if tail:
|
||||
|
@ -546,6 +549,9 @@ class FileContainer:
|
|||
fcntl.fcntl(fd, fcntl.F_SETFD, fd | fcntl.FD_CLOEXEC)
|
||||
firstLine = self.__handler.readline()
|
||||
# Computes the MD5 of the first line.
|
||||
if isinstance(firstLine, unicode):
|
||||
myHash = md5sum(firstLine.encode('utf-8')).digest()
|
||||
else:
|
||||
myHash = md5sum(firstLine).digest()
|
||||
stats = os.fstat(self.__handler.fileno())
|
||||
# Compare hash and inode
|
||||
|
|
Loading…
Reference in New Issue