From aed118e92c5a882e3e9db0c5401cc02512d4ebbd Mon Sep 17 00:00:00 2001 From: Deokhyun Kim Date: Fri, 13 Oct 2017 14:52:31 +0900 Subject: [PATCH] Use secure atcmd on log to protect private information. Change-Id: I24d898da980c7e15b480967cbbfa3af95f6dfdbd Signed-off-by: Deokhyun Kim Signed-off-by: DoHyun Pyun --- ag-agent/bluetooth-ag-agent.c | 2 +- hf-agent/bluetooth-hf-agent.c | 156 +++++++++++++++++++++--------------------- 2 files changed, 79 insertions(+), 79 deletions(-) diff --git a/ag-agent/bluetooth-ag-agent.c b/ag-agent/bluetooth-ag-agent.c index fe6bb3e..00cb6c2 100644 --- a/ag-agent/bluetooth-ag-agent.c +++ b/ag-agent/bluetooth-ag-agent.c @@ -2364,7 +2364,7 @@ static struct event at_event_callbacks[] = { int num_of_secure_command = 4; static const char* secure_command[] = {"CLCC", "CLIP", "CPBR", "CCWA"}; -void __bt_ag_agent_print_at_buffer(char *message, const char *buf) +static void __bt_ag_agent_print_at_buffer(char *message, const char *buf) { int i = 0; diff --git a/hf-agent/bluetooth-hf-agent.c b/hf-agent/bluetooth-hf-agent.c index 8ea0c85..95a46b4 100755 --- a/hf-agent/bluetooth-hf-agent.c +++ b/hf-agent/bluetooth-hf-agent.c @@ -220,6 +220,73 @@ static GVariant *bt_hf_agent_request_call_list(void); static int bt_hf_agent_send_at_cmd(GDBusMethodInvocation *context, char *atcmd); static int hf_handle_rx_at_cmd(bt_hf_agent_info_t *bt_hf_info, const char *buf); + +void __bt_hf_agent_print_at_buffer(char *message, const char *buf) +{ + + int i = 0; + char s[BT_HF_DATA_BUF_SIZE] = {0, }; + gboolean hide = FALSE; + + gboolean has_clcc = FALSE; + gboolean has_clip = FALSE; + gboolean has_ccwa = FALSE; + char *xsat_ptr; + + strncpy(s, buf, BT_HF_DATA_BUF_SIZE - 1); + + has_clcc = strstr(buf, "CLCC:") ? TRUE : FALSE; + if (has_clcc == TRUE) + goto done; + has_clip = strstr(buf, "+CLIP:") ? TRUE : FALSE; + if (has_clip == TRUE) + goto done; + has_ccwa = strstr(buf, "+CCWA:") ? TRUE : FALSE; + +done: + /* +XSAT: 11,DISC */ + xsat_ptr = strstr(s, "11,DISC,"); + if (xsat_ptr) { + xsat_ptr = xsat_ptr + 8; + int x = 0; + while (xsat_ptr[x] != '\0' && xsat_ptr[x] != '\r' && xsat_ptr[x] != '\n') { + xsat_ptr[x] = 'X'; + x++; + } + } + + /* AT+XSAT=11,Q_CT,X,XXXX */ + xsat_ptr = strstr(s, "11,Q_CT,"); + if (xsat_ptr) { + xsat_ptr = xsat_ptr + 8; + int x = 0; + while (xsat_ptr[x] != '\0' && xsat_ptr[x] != '\r' && xsat_ptr[x] != '\n') { + if (x > 1) /* ignore 0 and 1 position */ + xsat_ptr[x] = 'X'; + x++; + } + } + + i = 0; + while (s[i] != '\0') { + if (s[i] == '\r' || s[i] == '\n') { + s[i] = '.'; + } else { + if (s[i] == '\"') + hide = hide ? FALSE : TRUE; + else if ((has_clcc || has_clip || has_ccwa) && hide) { + if (i % 2) + s[i] = 'X'; + } + } + i++; + } + if (message) + INFO("%s Buffer = %s, Length = %d ", message, s, strlen(s)); + else + INFO("%s", s); +} + static GQuark __bt_hf_agent_error_quark(void) { DBG(""); @@ -433,7 +500,7 @@ static void __hf_agent_method(GDBusConnection *connection, g_variant_get(parameters, "(&s)", &cmd); - DBG("Going to call SendAtCmd, cmd is = [%s]\n", cmd); + DBG("Going to call SendAtCmd\n"); ret = bt_hf_agent_send_at_cmd(context, cmd); if (ret) goto fail; @@ -787,10 +854,8 @@ gboolean __bt_hf_agent_add_queue(GDBusMethodInvocation *context, char *at, if (bt_hf_info.slc == FALSE) return FALSE; - if (pending_flag) - DBG("*** Add Pending queue request for = %s **** ", at); - else - DBG("Add Pending queue respnse for = %s ", at); + DBG("Add Pending queue. (pending_flag is %s)", + pending_flag ? "TRUE" : "FALSE"); bt_hf_agent_send_at_info *cmd = g_new0(bt_hf_agent_send_at_info, 1); cmd->id = ++g_id; @@ -1429,72 +1494,6 @@ static void __bt_hf_agent_handle_codec_select(bt_hf_agent_info_t *bt_hf_info, ERR("Failed to select the Codec"); } -void __bt_hf_agent_print_at_buffer(char *message, const char *buf) -{ - - int i = 0; - char s[BT_HF_DATA_BUF_SIZE] = {0, }; - gboolean hide = FALSE; - - gboolean has_clcc = FALSE; - gboolean has_clip = FALSE; - gboolean has_ccwa = FALSE; - char *xsat_ptr; - - strncpy(s, buf, BT_HF_DATA_BUF_SIZE - 1); - - has_clcc = strstr(buf, "CLCC:") ? TRUE : FALSE; - if (has_clcc == TRUE) - goto done; - has_clip = strstr(buf, "+CLIP:") ? TRUE : FALSE; - if (has_clip == TRUE) - goto done; - has_ccwa = strstr(buf, "+CCWA:") ? TRUE : FALSE; - -done: - /* +XSAT: 11,DISC */ - xsat_ptr = strstr(s, "11,DISC,"); - if (xsat_ptr) { - xsat_ptr = xsat_ptr + 8; - int x = 0; - while (xsat_ptr[x] != '\0' && xsat_ptr[x] != '\r' && xsat_ptr[x] != '\n') { - xsat_ptr[x] = 'X'; - x++; - } - } - - /* AT+XSAT=11,Q_CT,X,XXXX */ - xsat_ptr = strstr(s, "11,Q_CT,"); - if (xsat_ptr) { - xsat_ptr = xsat_ptr + 8; - int x = 0; - while (xsat_ptr[x] != '\0' && xsat_ptr[x] != '\r' && xsat_ptr[x] != '\n') { - if (x > 1) /* ignore 0 and 1 position */ - xsat_ptr[x] = 'X'; - x++; - } - } - - i = 0; - while (s[i] != '\0') { - if (s[i] == '\r' || s[i] == '\n') { - s[i] = '.'; - } else { - if (s[i] == '\"') - hide = hide ? FALSE : TRUE; - else if ((has_clcc || has_clip || has_ccwa) && hide) { - if (i % 2) - s[i] = 'X'; - } - } - i++; - } - if (message) - INFO("%s Buffer = %s, Length = %d ", message, s, strlen(s)); - else - INFO("%s", s); -} - static int __bt_hf_agent_handler_ciev(bt_hf_agent_info_t *bt_hf_info, const char *buf) { gchar *indicator; @@ -2084,12 +2083,12 @@ static gboolean __bt_hf_send_only_without_queue(bt_hf_agent_info_t *bt_hf_info, g_io_channel_flush(io_chan, NULL); if (count > 2 && data[2] == 'D') { /* ATDXXXXX */ - INFO("Send only buffer size =[%d] No len = %d - Send <<<<<| %s", - count, count - 6, "ATDXXXXXXX"); + INFO("[HF AT CMD] Send only without queue <<<<<: Buffer = %s, Length = %d ", + "ATDXXXXXXX", count); snprintf(prev_cmd, BT_HF_CMD_BUF_SIZE, "%s", data); } else { - INFO("No queue....Send only buffer size =[%d] - Send <<<<<| %s", - count, data); + __bt_hf_agent_print_at_buffer("[HF AT CMD] Send only without queue <<<<<:", + data); } send_flag++; @@ -2119,10 +2118,11 @@ static gboolean __bt_hf_send_only(bt_hf_agent_info_t *bt_hf_info, gchar *data, g_io_channel_flush(io_chan, NULL); if (count > 2 && data[2] == 'D') /* ATDXXXXX */ - INFO("Send only buffer size =[%d] No len = %d - Send <<<<<| %s", - count, count - 6, "ATDXXXXXXX"); + INFO("[HF AT CMD] Send only <<<<<: Buffer = %s, Length = %d ", + "ATDXXXXXXX", count); else - INFO("Send only buffer size =[%d] - Send <<<<<| %s", count, data); + __bt_hf_agent_print_at_buffer("[HF AT CMD] Send only <<<<<:", + data); send_flag++; DBG("Ref %d(after) on Send only buffer size =[%d] - Send <<<<<| %s", -- 2.7.4