Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[mms_codec] Fixed decoding of the From field
The text it may contain must be treated as Encoded-string-value
  • Loading branch information
monich committed Apr 15, 2014
1 parent f288948 commit 966bb5c
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 22 deletions.
44 changes: 22 additions & 22 deletions mms-lib/src/mms_codec.c
Expand Up @@ -527,32 +527,28 @@ static char *decode_encoded_string_with_mib_enum(const unsigned char *p,
&bytes_read, &bytes_written, NULL);
}

static gboolean extract_encoded_text(struct wsp_header_iter *iter, void *user)
static char* decode_encoded_text(enum wsp_value_type t,
const unsigned char *p, unsigned int l)
{
char **out = user;
const unsigned char *p;
unsigned int l;
const char *text;
char *dec_text;

p = wsp_header_iter_get_val(iter);
l = wsp_header_iter_get_val_len(iter);

switch (wsp_header_iter_get_val_type(iter)) {
switch (t) {
case WSP_VALUE_TYPE_TEXT:
/* Text-string */
text = wsp_decode_text(p, l, NULL);
dec_text = g_strdup(text);
break;
return g_strdup(wsp_decode_text(p, l, NULL));
case WSP_VALUE_TYPE_LONG:
/* (Value-len) Char-set Text-string */
dec_text = decode_encoded_string_with_mib_enum(p, l);
break;
return decode_encoded_string_with_mib_enum(p, l);
default:
case WSP_VALUE_TYPE_SHORT:
dec_text = NULL;
break;
return NULL;
}
}

static gboolean extract_encoded_text(struct wsp_header_iter *iter, void *user)
{
char **out = user;
char *dec_text = decode_encoded_text(
wsp_header_iter_get_val_type(iter),
wsp_header_iter_get_val(iter),
wsp_header_iter_get_val_len(iter));

if (dec_text == NULL)
return FALSE;
Expand Down Expand Up @@ -685,7 +681,8 @@ static gboolean extract_from(struct wsp_header_iter *iter, void *user)
char **out = user;
const unsigned char *p;
unsigned int l;
const char *text;
enum wsp_value_type t;
char *text;

if (wsp_header_iter_get_val_type(iter) != WSP_VALUE_TYPE_LONG)
return FALSE;
Expand All @@ -701,11 +698,14 @@ static gboolean extract_from(struct wsp_header_iter *iter, void *user)
return TRUE;
}

text = wsp_decode_text(p + 1, l - 1, NULL);
if (!wsp_decode_field(p + 1, l - 1, &t, (const void **)&p, &l, NULL))
return FALSE;

text = decode_encoded_text(t, p, l);
if (text == NULL)
return FALSE;

*out = g_strdup(text);
*out = text;

return TRUE;
}
Expand Down
Binary file added mms-lib/test/mms_codec/data/m-retrieve_4.conf
Binary file not shown.
1 change: 1 addition & 0 deletions mms-lib/test/mms_codec/test_mms_codec.c
Expand Up @@ -61,6 +61,7 @@ int main(int argc, char* argv[])
"m-retrieve_1.conf",
"m-retrieve_2.conf",
"m-retrieve_3.conf",
"m-retrieve_4.conf",
"m-notifyresp.ind",
"m-read-rec.ind",
"m-send.conf"
Expand Down

0 comments on commit 966bb5c

Please sign in to comment.