From 8a4a219a14591481708bf6f0c19591543eb60dfc Mon Sep 17 00:00:00 2001 From: Jarrod Johnson Date: Wed, 9 Oct 2019 15:06:23 -0400 Subject: [PATCH] Fix two more python2 string behavior In python3, bytes[n] is an int, but not in python2. Sidestep by doing bytearray() for both, which is consistent between the two. --- confluent_server/confluent/config/configmanager.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/confluent_server/confluent/config/configmanager.py b/confluent_server/confluent/config/configmanager.py index 978a4c01..9e324385 100644 --- a/confluent_server/confluent/config/configmanager.py +++ b/confluent_server/confluent/config/configmanager.py @@ -405,12 +405,12 @@ def decrypt_value(cryptvalue, raise Exception("bad HMAC value on crypted value") decrypter = AES.new(key, AES.MODE_CBC, iv) value = decrypter.decrypt(cipherdata) - padsize = ord(value[-1]) + padsize = bytearray(value)[-1] pad = value[-padsize:] # Note that I cannot grasp what could be done with a subliminal # channel in padding in this case, but check the padding anyway - for padbyte in pad: - if ord(padbyte) != padsize: + for padbyte in bytearray(pad): + if padbyte != padsize: raise Exception("bad padding in encrypted value") return value[0:-padsize] else: