diff 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
line wrap: on
line diff
--- a/uicc/bfsearch.c	Thu Feb 25 18:40:59 2021 +0000
+++ b/uicc/bfsearch.c	Thu Feb 25 20:17:10 2021 +0000
@@ -25,10 +25,10 @@
 		rc = elem_select_op(path[n]);
 		if (rc < 0)
 			return(rc);
-		if (!rc) {
+		if ((sim_resp_sw & 0xFF00) != 0x6100) {
 			fprintf(stderr,
-				"error selecting 0x%04X: file not found\n",
-				path[n]);
+				"error selecting 0x%04X: SW resp 0x%04X\n",
+				path[n], sim_resp_sw);
 			return(-1);
 		}
 	}
@@ -51,8 +51,15 @@
 		rc = elem_select_op(bfs);
 		if (rc < 0)
 			return(rc);
-		if (!rc)
+		if (sim_resp_sw == 0x6A82)
 			continue;
+		if ((sim_resp_sw & 0xFF00) != 0x6100) {
+			for (n = 0; n < pathlen; n++)
+				fprintf(outf, "%04X/", path[n]);
+			fprintf(outf, "%04X: SW response 0x%04X", bfs,
+				sim_resp_sw);
+			continue;
+		}
 		rc = get_response_op();
 		if (rc < 0)
 			return(rc);
@@ -87,10 +94,10 @@
 		rc = elem_select_op(path[pathlen-1]);
 		if (rc < 0)
 			return(rc);
-		if (!rc) {
+		if ((sim_resp_sw & 0xFF00) != 0x6100) {
 			fprintf(stderr,
-			"reselecting starting file ID 0x%04X not-found error\n",
-				path[pathlen-1]);
+			"reselecting starting file ID 0x%04X: SW resp 0x%04X\n",
+				path[pathlen-1], sim_resp_sw);
 			return(-1);
 		}
 	}