tests: Explicit str/bytes conversion for key_lifetime_in_memory

This is needed for python3.

Signed-off-by: Jouni Malinen <j@w1.fi>
This commit is contained in:
Jouni Malinen 2019-02-02 18:50:13 +02:00
parent a42ec6611c
commit b3361e5dc9
4 changed files with 6 additions and 3 deletions

View file

@ -5083,6 +5083,7 @@ def test_wpa2_eap_ttls_pap_key_lifetime_in_memory(dev, apdev, params):
# eloop before reading process memory. # eloop before reading process memory.
time.sleep(1) time.sleep(1)
dev[0].ping() dev[0].ping()
password = password.encode()
buf = read_process_memory(pid, password) buf = read_process_memory(pid, password)
dev[0].request("DISCONNECT") dev[0].request("DISCONNECT")

View file

@ -2329,7 +2329,7 @@ def read_process_memory(pid, key=None):
buf = bytes() buf = bytes()
logger.info("Reading process memory (pid=%d)" % pid) logger.info("Reading process memory (pid=%d)" % pid)
with open('/proc/%d/maps' % pid, 'r') as maps, \ with open('/proc/%d/maps' % pid, 'r') as maps, \
open('/proc/%d/mem' % pid, 'r') as mem: open('/proc/%d/mem' % pid, 'rb') as mem:
for l in maps.readlines(): for l in maps.readlines():
m = re.match(r'([0-9a-f]+)-([0-9a-f]+) ([-r][-w][-x][-p])', l) m = re.match(r'([0-9a-f]+)-([0-9a-f]+) ([-r][-w][-x][-p])', l)
if not m: if not m:
@ -2360,7 +2360,7 @@ def verify_not_present(buf, key, fname, keyname):
return return
prefix = 2048 if pos > 2048 else pos prefix = 2048 if pos > 2048 else pos
with open(fname + keyname, 'w') as f: with open(fname + keyname, 'wb') as f:
f.write(buf[pos - prefix:pos + 2048]) f.write(buf[pos - prefix:pos + 2048])
raise Exception(keyname + " found after disassociation") raise Exception(keyname + " found after disassociation")

View file

@ -1,5 +1,5 @@
# EAP Re-authentication Protocol (ERP) tests # EAP Re-authentication Protocol (ERP) tests
# Copyright (c) 2014-2015, Jouni Malinen <j@w1.fi> # Copyright (c) 2014-2019, Jouni Malinen <j@w1.fi>
# #
# This software may be distributed under the terms of the BSD license. # This software may be distributed under the terms of the BSD license.
# See README for more details. # See README for more details.
@ -275,6 +275,7 @@ def test_erp_key_lifetime_in_memory(dev, apdev, params):
# eloop before reading process memory. # eloop before reading process memory.
time.sleep(1) time.sleep(1)
dev[0].ping() dev[0].ping()
password = password.encode()
buf = read_process_memory(pid, password) buf = read_process_memory(pid, password)
dev[0].request("DISCONNECT") dev[0].request("DISCONNECT")

View file

@ -362,6 +362,7 @@ def test_sae_key_lifetime_in_memory(dev, apdev, params):
# eloop before reading process memory. # eloop before reading process memory.
time.sleep(1) time.sleep(1)
dev[0].ping() dev[0].ping()
password = password.encode()
buf = read_process_memory(pid, password) buf = read_process_memory(pid, password)
dev[0].request("DISCONNECT") dev[0].request("DISCONNECT")