changeset 784:839bf41e7be0

simagent: X command parsing bugfix
author Mychaela Falconia <falcon@freecalypso.org>
date Sat, 13 Mar 2021 22:08:48 +0000
parents c136a1a2474b
children 56506e9165bc
files target-utils/simagent/exchange.c
diffstat 1 files changed, 5 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/target-utils/simagent/exchange.c	Sat Mar 13 22:06:08 2021 +0000
+++ b/target-utils/simagent/exchange.c	Sat Mar 13 22:08:48 2021 +0000
@@ -92,6 +92,7 @@
 	char *argstr;
 {
 	u8 cmd[260];
+	unsigned count;
 	int rc;
 
 	if (sim_if_state != 2) {
@@ -101,7 +102,8 @@
 	rc = decode_hex_string_arg(argstr, cmd, 260);
 	if (rc < 0)
 		return;
-	if (rc < 5) {
+	count = rc;
+	if (count < 5) {
 		printf("ERROR: command APDU is shorter than 5 bytes\n");
 		return;
 	}
@@ -111,8 +113,8 @@
 	rc = send_to_sim(cmd, 5);
 	if (rc < 0)
 		return;
-	if (rc > 5)
-		exchange_data_out(cmd[1], cmd + 5, rc - 5);
+	if (count > 5)
+		exchange_data_out(cmd[1], cmd + 5, count - 5);
 	else
 		exchange_data_in(cmd[1], cmd[4]);
 }