aboutsummaryrefslogtreecommitdiffstats
path: root/src/utils
diff options
context:
space:
mode:
authorJouni Malinen <j@w1.fi>2012-03-03 12:35:14 +0200
committerJouni Malinen <j@w1.fi>2012-03-03 12:35:14 +0200
commitf41ed0f8452de767aa2469ab03ffbbd0fe76b455 (patch)
tree0b27eb4e05d20f12e2a56a5faeba2721b3fcc8e5 /src/utils
parent400020cbe82d1c6fae515f4c4c2dcd4e55b6253a (diff)
downloadexternal_wpa_supplicant_8_ti-f41ed0f8452de767aa2469ab03ffbbd0fe76b455.zip
external_wpa_supplicant_8_ti-f41ed0f8452de767aa2469ab03ffbbd0fe76b455.tar.gz
external_wpa_supplicant_8_ti-f41ed0f8452de767aa2469ab03ffbbd0fe76b455.tar.bz2
SCARD: Reindent scard_parse_fsp_templ()
This was left at incorrect indentation level when moved to a separate function. Signed-hostap: Jouni Malinen <j@w1.fi>
Diffstat (limited to 'src/utils')
-rw-r--r--src/utils/pcsc_funcs.c103
1 files changed, 51 insertions, 52 deletions
diff --git a/src/utils/pcsc_funcs.c b/src/utils/pcsc_funcs.c
index d2f58e3..4c18bc1 100644
--- a/src/utils/pcsc_funcs.c
+++ b/src/utils/pcsc_funcs.c
@@ -234,60 +234,59 @@ static int scard_read_record(struct scard_data *scard,
static int scard_parse_fsp_templ(unsigned char *buf, size_t buf_len,
int *ps_do, int *file_len)
{
- unsigned char *pos, *end;
-
- if (ps_do)
- *ps_do = -1;
- if (file_len)
- *file_len = -1;
-
- pos = buf;
- end = pos + buf_len;
- if (*pos != USIM_FSP_TEMPL_TAG) {
- wpa_printf(MSG_DEBUG, "SCARD: file header did not "
- "start with FSP template tag");
- return -1;
+ unsigned char *pos, *end;
+
+ if (ps_do)
+ *ps_do = -1;
+ if (file_len)
+ *file_len = -1;
+
+ pos = buf;
+ end = pos + buf_len;
+ if (*pos != USIM_FSP_TEMPL_TAG) {
+ wpa_printf(MSG_DEBUG, "SCARD: file header did not "
+ "start with FSP template tag");
+ return -1;
+ }
+ pos++;
+ if (pos >= end)
+ return -1;
+ if ((pos + pos[0]) < end)
+ end = pos + 1 + pos[0];
+ pos++;
+ wpa_hexdump(MSG_DEBUG, "SCARD: file header FSP template",
+ pos, end - pos);
+
+ while (pos + 1 < end) {
+ wpa_printf(MSG_MSGDUMP, "SCARD: file header TLV 0x%02x len=%d",
+ pos[0], pos[1]);
+ if (pos + 2 + pos[1] > end)
+ break;
+
+ if (pos[0] == USIM_TLV_FILE_SIZE &&
+ (pos[1] == 1 || pos[1] == 2) && file_len) {
+ if (pos[1] == 1)
+ *file_len = (int) pos[2];
+ else
+ *file_len = ((int) pos[2] << 8) |
+ (int) pos[3];
+ wpa_printf(MSG_DEBUG, "SCARD: file_size=%d",
+ *file_len);
}
- pos++;
- if (pos >= end)
- return -1;
- if ((pos + pos[0]) < end)
- end = pos + 1 + pos[0];
- pos++;
- wpa_hexdump(MSG_DEBUG, "SCARD: file header FSP template",
- pos, end - pos);
-
- while (pos + 1 < end) {
- wpa_printf(MSG_MSGDUMP, "SCARD: file header TLV "
- "0x%02x len=%d", pos[0], pos[1]);
- if (pos + 2 + pos[1] > end)
- break;
-
- if (pos[0] == USIM_TLV_FILE_SIZE &&
- (pos[1] == 1 || pos[1] == 2) && file_len) {
- if (pos[1] == 1)
- *file_len = (int) pos[2];
- else
- *file_len = ((int) pos[2] << 8) |
- (int) pos[3];
- wpa_printf(MSG_DEBUG, "SCARD: file_size=%d",
- *file_len);
- }
-
- if (pos[0] == USIM_TLV_PIN_STATUS_TEMPLATE &&
- pos[1] >= 2 && pos[2] == USIM_PS_DO_TAG &&
- pos[3] >= 1 && ps_do) {
- wpa_printf(MSG_DEBUG, "SCARD: PS_DO=0x%02x",
- pos[4]);
- *ps_do = (int) pos[4];
- }
-
- pos += 2 + pos[1];
-
- if (pos == end)
- return 0;
+
+ if (pos[0] == USIM_TLV_PIN_STATUS_TEMPLATE &&
+ pos[1] >= 2 && pos[2] == USIM_PS_DO_TAG &&
+ pos[3] >= 1 && ps_do) {
+ wpa_printf(MSG_DEBUG, "SCARD: PS_DO=0x%02x", pos[4]);
+ *ps_do = (int) pos[4];
}
- return -1;
+
+ pos += 2 + pos[1];
+
+ if (pos == end)
+ return 0;
+ }
+ return -1;
}