As per the ETSI TS 102 223 section 6.5.4,
If the terminal receives an icon, and either
an empty or no alpha identifier/text string
is given by the UICC, than the terminal shall
reject the command with general result
"Command data not understood by terminal".
---
src/stk.c | 114 ++++++++++++++++++++++++++++++++++++++++++-------------------
1 files changed, 79 insertions(+), 35 deletions(-)
diff --git a/src/stk.c b/src/stk.c
index bec46ea..e3236c1 100644
--- a/src/stk.c
+++ b/src/stk.c
@@ -316,6 +316,20 @@ static char *dbus_apply_text_attributes(const char *text,
return stk_text_to_html(text, buf, attr->len / 4);
}
+static gboolean check_text( const char *in, const unsigned char icon_id,
+ const struct stk_text_attribute *attr,
+ char **out)
+{
+ if ((in == NULL || strlen(in) < 1) && icon_id != 0)
+ return FALSE;
+
+ *out = dbus_apply_text_attributes(in ? in : "", attr);
+ if (*out == NULL)
+ return FALSE;
+
+ return TRUE;
+}
+
static struct stk_menu *stk_menu_create(const char *title,
const struct stk_text_attribute *title_attr,
const struct stk_icon_id *icon, GSList *items,
@@ -341,10 +355,8 @@ static struct stk_menu *stk_menu_create(const char *title,
if (ret == NULL)
return NULL;
- ret->title = dbus_apply_text_attributes(title ? title : "",
- title_attr);
- if (ret->title == NULL)
- ret->title = g_strdup(title ? title : "");
+ if (check_text(title, icon->id, title_attr, &ret->title) == FALSE)
+ return NULL;
memcpy(&ret->icon, icon, sizeof(ret->icon));
ret->items = g_new0(struct stk_menu_item, len + 1);
@@ -841,6 +853,15 @@ static gboolean handle_command_send_sms(const struct stk_command
*cmd,
struct ofono_sms *sms;
GSList msg_list;
struct ofono_uuid uuid;
+ char *text;
+
+ if (check_text(cmd->send_sms.alpha_id, cmd->send_sms.icon_id.id,
+ &cmd->send_sms.text_attr, &text) == FALSE) {
+ rsp->result.type = STK_RESULT_TYPE_DATA_NOT_UNDERSTOOD;
+ return TRUE;
+ }
+
+ g_free(text);
sms_atom = __ofono_modem_find_atom(modem, OFONO_ATOM_TYPE_SMS);
@@ -880,11 +901,10 @@ static gboolean handle_command_set_idle_text(const struct
stk_command *cmd,
const char *path = __ofono_atom_get_path(stk->atom);
char *idle_mode_text;
- idle_mode_text = dbus_apply_text_attributes(
- cmd->setup_idle_mode_text.text,
- &cmd->setup_idle_mode_text.text_attr);
-
- if (idle_mode_text == NULL) {
+ if (check_text(cmd->setup_idle_mode_text.text,
+ cmd->setup_idle_mode_text.icon_id.id,
+ &cmd->setup_idle_mode_text.text_attr,
+ &idle_mode_text) == FALSE) {
rsp->result.type = STK_RESULT_TYPE_DATA_NOT_UNDERSTOOD;
return TRUE;
}
@@ -1280,10 +1300,11 @@ static gboolean handle_command_display_text(const struct
stk_command *cmd,
struct stk_command_display_text *dt = &stk->pending_cmd->display_text;
uint8_t qualifier = stk->pending_cmd->qualifier;
ofono_bool_t priority = (qualifier & (1 << 0)) != 0;
- char *text = dbus_apply_text_attributes(dt->text, &dt->text_attr);
+ char *text;
int err;
- if (text == NULL) {
+ if (check_text(dt->text, dt->icon_id.id, &dt->text_attr,
+ &text) == FALSE) {
rsp->result.type = STK_RESULT_TYPE_DATA_NOT_UNDERSTOOD;
return TRUE;
}
@@ -1436,7 +1457,7 @@ static gboolean handle_command_get_inkey(const struct stk_command
*cmd,
{
int timeout = stk->timeout * 1000;
const struct stk_command_get_inkey *gi = &cmd->get_inkey;
- char *text = dbus_apply_text_attributes(gi->text, &gi->text_attr);
+ char *text;
uint8_t qualifier = stk->pending_cmd->qualifier;
gboolean alphabet = (qualifier & (1 << 0)) != 0;
gboolean ucs2 = (qualifier & (1 << 1)) != 0;
@@ -1447,7 +1468,8 @@ static gboolean handle_command_get_inkey(const struct stk_command
*cmd,
*/
int err;
- if (text == NULL) {
+ if (check_text(gi->text, gi->icon_id.id, &gi->text_attr,
+ &text) == FALSE) {
rsp->result.type = STK_RESULT_TYPE_DATA_NOT_UNDERSTOOD;
return TRUE;
}
@@ -1534,14 +1556,15 @@ static gboolean handle_command_get_input(const struct stk_command
*cmd,
{
int timeout = stk->timeout * 1000;
const struct stk_command_get_input *gi = &cmd->get_input;
- char *text = dbus_apply_text_attributes(gi->text, &gi->text_attr);
+ char *text;
uint8_t qualifier = stk->pending_cmd->qualifier;
gboolean alphabet = (qualifier & (1 << 0)) != 0;
gboolean ucs2 = (qualifier & (1 << 1)) != 0;
gboolean hidden = (qualifier & (1 << 2)) != 0;
int err;
- if (text == NULL) {
+ if (check_text(gi->text, gi->icon_id.id, &gi->text_attr,
+ &text) == FALSE) {
rsp->result.type = STK_RESULT_TYPE_DATA_NOT_UNDERSTOOD;
return TRUE;
}
@@ -1664,14 +1687,10 @@ static void confirm_call_cb(enum stk_agent_result result, gboolean
confirm,
return;
}
- if (sc->alpha_id_call_setup) {
- alpha_id = dbus_apply_text_attributes(sc->alpha_id_call_setup,
- &sc->text_attr_call_setup);
- if (alpha_id == NULL) {
- send_simple_response(stk,
- STK_RESULT_TYPE_DATA_NOT_UNDERSTOOD);
- return;
- }
+ if (check_text(sc->alpha_id_call_setup, sc->icon_id_call_setup.id,
+ &sc->text_attr_call_setup, &alpha_id) == FALSE) {
+ send_simple_response(stk, STK_RESULT_TYPE_DATA_NOT_UNDERSTOOD);
+ return;
}
err = __ofono_voicecall_dial(vc, sc->addr.number, sc->addr.ton_npi,
@@ -1722,7 +1741,8 @@ static gboolean handle_command_set_up_call(const struct stk_command
*cmd,
const struct stk_command_setup_call *sc = &cmd->setup_call;
uint8_t qualifier = cmd->qualifier;
static unsigned char busy_on_call_result[] = { 0x02 };
- char *alpha_id = NULL;
+ char *alpha_id_usr_cfm;
+ char *alpha_id_cs;
struct ofono_voicecall *vc = NULL;
struct ofono_atom *vc_atom;
int err;
@@ -1758,18 +1778,25 @@ static gboolean handle_command_set_up_call(const struct
stk_command *cmd,
return TRUE;
}
- alpha_id = dbus_apply_text_attributes(sc->alpha_id_usr_cfm ?
- sc->alpha_id_usr_cfm : "",
- &sc->text_attr_usr_cfm);
- if (alpha_id == NULL) {
+ if (check_text(sc->alpha_id_call_setup, sc->icon_id_call_setup.id,
+ &sc->text_attr_call_setup, &alpha_id_cs) == FALSE) {
rsp->result.type = STK_RESULT_TYPE_DATA_NOT_UNDERSTOOD;
return TRUE;
}
- err = stk_agent_confirm_call(stk->current_agent, alpha_id,
- &sc->icon_id_usr_cfm, confirm_call_cb,
- stk, NULL, stk->timeout * 1000);
- g_free(alpha_id);
+ g_free(alpha_id_cs);
+
+ if (check_text(sc->alpha_id_usr_cfm, sc->icon_id_usr_cfm.id,
+ &sc->text_attr_usr_cfm, &alpha_id_usr_cfm) == FALSE) {
+ rsp->result.type = STK_RESULT_TYPE_DATA_NOT_UNDERSTOOD;
+ return TRUE;
+ }
+
+ err = stk_agent_confirm_call(stk->current_agent, alpha_id_usr_cfm,
+ &sc->icon_id_usr_cfm, confirm_call_cb,
+ stk, NULL, stk->timeout * 1000);
+
+ g_free(alpha_id_usr_cfm);
if (err < 0) {
/*
@@ -1956,9 +1983,18 @@ static gboolean handle_command_refresh(const struct stk_command
*cmd,
struct ofono_stk *stk)
{
GSList *l;
+ char *alpha_id;
DBG("");
+ if (check_text(cmd->refresh.alpha_id, cmd->refresh.icon_id.id,
+ &cmd->refresh.text_attr, &alpha_id) == FALSE) {
+ rsp->result.type = STK_RESULT_TYPE_DATA_NOT_UNDERSTOOD;
+ return TRUE;
+ }
+
+ g_free(alpha_id);
+
switch (cmd->qualifier) {
case 0:
DBG("NAA Initialization and "
@@ -2144,6 +2180,15 @@ static gboolean handle_command_send_dtmf(const struct stk_command
*cmd,
char *dtmf_from = "01234567890abcABC";
char *dtmf_to = "01234567890*#p*#p";
int err, pos;
+ char *alpha_id;
+
+ if (check_text(cmd->send_dtmf.alpha_id, cmd->send_dtmf.icon_id.id,
+ &cmd->send_dtmf.text_attr, &alpha_id) == FALSE) {
+ rsp->result.type = STK_RESULT_TYPE_DATA_NOT_UNDERSTOOD;
+ return TRUE;
+ }
+
+ g_free(alpha_id);
vc_atom = __ofono_modem_find_atom(__ofono_atom_get_modem(stk->atom),
OFONO_ATOM_TYPE_VOICECALL);
@@ -2299,9 +2344,8 @@ static gboolean handle_command_play_tone(const struct stk_command
*cmd,
return TRUE;
}
- text = dbus_apply_text_attributes(pt->alpha_id ? pt->alpha_id : "",
- &pt->text_attr);
- if (text == NULL) {
+ if (check_text(pt->alpha_id, pt->icon_id.id, &pt->text_attr,
+ &text) == FALSE) {
rsp->result.type = STK_RESULT_TYPE_DATA_NOT_UNDERSTOOD;
return TRUE;
--
1.7.0.4