aboutsummaryrefslogtreecommitdiffstats
path: root/wpa_supplicant/examples
diff options
context:
space:
mode:
authorJouni Malinen <jouni@qca.qualcomm.com>2013-11-29 10:46:41 (GMT)
committerJouni Malinen <j@w1.fi>2014-01-27 20:08:13 (GMT)
commit79ede5a7e6625cbe3321a13ee46bc58113a6db7f (patch)
tree450876aff64358e1dccd4a8f7dfaad8fa6cedb0d /wpa_supplicant/examples
parentab1db08c0505804676a9862b59ed9b8800949957 (diff)
downloadhostap-79ede5a7e6625cbe3321a13ee46bc58113a6db7f.zip
hostap-79ede5a7e6625cbe3321a13ee46bc58113a6db7f.tar.gz
hostap-79ede5a7e6625cbe3321a13ee46bc58113a6db7f.tar.bz2
WPS NFC: Validate ctrl_iface response before decoding it
If the operation fails for any reason ("FAIL" response), it is cleaner to return error clearly instead of hitting an exception in the hex decoder. Signed-hostap: Jouni Malinen <jouni@qca.qualcomm.com>
Diffstat (limited to 'wpa_supplicant/examples')
-rwxr-xr-xwpa_supplicant/examples/wps-nfc.py13
1 files changed, 10 insertions, 3 deletions
diff --git a/wpa_supplicant/examples/wps-nfc.py b/wpa_supplicant/examples/wps-nfc.py
index e1d59e9..ea00497 100755
--- a/wpa_supplicant/examples/wps-nfc.py
+++ b/wpa_supplicant/examples/wps-nfc.py
@@ -75,7 +75,10 @@ def wpas_get_er_config_token(uuid):
wpas = wpas_connect()
if (wpas == None):
return None
- return wpas.request("WPS_ER_NFC_CONFIG_TOKEN NDEF " + uuid).rstrip().decode("hex")
+ ret = wpas.request("WPS_ER_NFC_CONFIG_TOKEN NDEF " + uuid)
+ if "FAIL" in ret:
+ return None
+ return ret.rstrip().decode("hex")
def wpas_get_password_token():
@@ -97,8 +100,12 @@ def wpas_get_handover_sel(uuid):
if (wpas == None):
return None
if uuid is None:
- return wpas.request("NFC_GET_HANDOVER_SEL NDEF WPS-CR").rstrip().decode("hex")
- return wpas.request("NFC_GET_HANDOVER_SEL NDEF WPS-CR " + uuid).rstrip().decode("hex")
+ res = wpas.request("NFC_GET_HANDOVER_SEL NDEF WPS-CR").rstrip()
+ else:
+ res = wpas.request("NFC_GET_HANDOVER_SEL NDEF WPS-CR " + uuid).rstrip()
+ if "FAIL" in res:
+ return None
+ return res.decode("hex")
def wpas_report_handover(req, sel, type):