comparison uicc/bfsearch.c @ 155:cb3c40ff443e

fc-uicc-tool bfsearch: handle more weird SW response cases
author Mychaela Falconia <falcon@freecalypso.org>
date Thu, 25 Feb 2021 20:17:10 +0000
parents 2ef31306be22
children 5f1f3f6fd865
comparison
equal deleted inserted replaced
154:6d93a51f01dc 155:cb3c40ff443e
23 23
24 for (n = 0; n < pathlen; n++) { 24 for (n = 0; n < pathlen; n++) {
25 rc = elem_select_op(path[n]); 25 rc = elem_select_op(path[n]);
26 if (rc < 0) 26 if (rc < 0)
27 return(rc); 27 return(rc);
28 if (!rc) { 28 if ((sim_resp_sw & 0xFF00) != 0x6100) {
29 fprintf(stderr, 29 fprintf(stderr,
30 "error selecting 0x%04X: file not found\n", 30 "error selecting 0x%04X: SW resp 0x%04X\n",
31 path[n]); 31 path[n], sim_resp_sw);
32 return(-1); 32 return(-1);
33 } 33 }
34 } 34 }
35 ndfc = 0; 35 ndfc = 0;
36 for (bfs = 0; bfs <= 0xFFFF; bfs++) { 36 for (bfs = 0; bfs <= 0xFFFF; bfs++) {
49 if (n < nsiblings) 49 if (n < nsiblings)
50 continue; 50 continue;
51 rc = elem_select_op(bfs); 51 rc = elem_select_op(bfs);
52 if (rc < 0) 52 if (rc < 0)
53 return(rc); 53 return(rc);
54 if (!rc) 54 if (sim_resp_sw == 0x6A82)
55 continue; 55 continue;
56 if ((sim_resp_sw & 0xFF00) != 0x6100) {
57 for (n = 0; n < pathlen; n++)
58 fprintf(outf, "%04X/", path[n]);
59 fprintf(outf, "%04X: SW response 0x%04X", bfs,
60 sim_resp_sw);
61 continue;
62 }
56 rc = get_response_op(); 63 rc = get_response_op();
57 if (rc < 0) 64 if (rc < 0)
58 return(rc); 65 return(rc);
59 tlv_file_desc = extract_select_resp_tag(0x82); 66 tlv_file_desc = extract_select_resp_tag(0x82);
60 if (!tlv_file_desc) 67 if (!tlv_file_desc)
85 putc('\n', outf); 92 putc('\n', outf);
86 } 93 }
87 rc = elem_select_op(path[pathlen-1]); 94 rc = elem_select_op(path[pathlen-1]);
88 if (rc < 0) 95 if (rc < 0)
89 return(rc); 96 return(rc);
90 if (!rc) { 97 if ((sim_resp_sw & 0xFF00) != 0x6100) {
91 fprintf(stderr, 98 fprintf(stderr,
92 "reselecting starting file ID 0x%04X not-found error\n", 99 "reselecting starting file ID 0x%04X: SW resp 0x%04X\n",
93 path[pathlen-1]); 100 path[pathlen-1], sim_resp_sw);
94 return(-1); 101 return(-1);
95 } 102 }
96 } 103 }
97 if (pathlen >= 8) 104 if (pathlen >= 8)
98 return(0); 105 return(0);