From b2afea37917ec29dc0fdaa772a9a4d0f73e19ba1 Mon Sep 17 00:00:00 2001 From: Caiwen Zhang Date: Thu, 27 Jun 2013 20:43:09 +0800 Subject: [PATCH] fix sim data length count error the data may be binary and it may contain '\0', if count its length with strlen, the length may be incorrect. Change-Id: I669c2dd1e5ec049acadc3e04ac3fb0cc25aee9ab --- src/s_sim.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/s_sim.c b/src/s_sim.c index af57b10..9c336eb 100644 --- a/src/s_sim.c +++ b/src/s_sim.c @@ -1311,7 +1311,7 @@ static void _response_get_file_data(TcorePending *p, int data_len, const void *d tmp = util_removeQuotes(res); res = util_hexStringToBytes(tmp); - res_len = strlen((const char *)res); + res_len = strlen(tmp) / 2; dbg("Response: [%s] Response length: [%d]", res, res_len); if ((sw1 == 0x90 && sw2 == 0x00) || sw1 == 0x91) { @@ -2846,7 +2846,7 @@ static void on_response_get_atr(TcorePending *p, int data_len, const void *data, tmp = util_removeQuotes(g_slist_nth_data(tokens, 0)); decoded_data = util_hexStringToBytes(tmp); - res.atr_length = strlen(decoded_data); + res.atr_length = strlen(tmp) / 2; memcpy((char *)res.atr, decoded_data, res.atr_length); g_free(tmp); g_free(decoded_data); -- 2.7.4