From: Denis Kenzior <denkenz@gmail.com>
To: ofono@ofono.org
Subject: Re: [PATCH 1/2] sms: SMS-DELIVER TP-OA Alphanum decoding and encoding fix
Date: Fri, 13 Feb 2015 09:13:14 -0600 [thread overview]
Message-ID: <54DE148A.9090407@gmail.com> (raw)
In-Reply-To: <1423830226-32024-2-git-send-email-tommi.kenakkala@tieto.com>
[-- Attachment #1: Type: text/plain, Size: 2376 bytes --]
Hi Tommi,
On 02/13/2015 06:23 AM, Tommi Kenakkala wrote:
> TP-OA max length comparisons were incorrect because TP-OA's 7-bit
> coded octets transport eleven 8-bit chars which take 23 bytes in UTF-8.
> Increase address array accordingly and don't compare byte length to
> character limit, but to a proper limit.
> ---
> src/smsutil.c | 12 +++++++++---
> src/smsutil.h | 6 +++++-
> 2 files changed, 14 insertions(+), 4 deletions(-)
>
> diff --git a/src/smsutil.c b/src/smsutil.c
> index be60ee9..213e50e 100644
> --- a/src/smsutil.c
> +++ b/src/smsutil.c
> @@ -524,7 +524,8 @@ static gboolean encode_validity_period(const struct sms_validity_period *vp,
> gboolean sms_encode_address_field(const struct sms_address *in, gboolean sc,
> unsigned char *pdu, int *offset)
> {
> - size_t len = strlen(in->address);
> + const char *addr = (const char *)&in->address;
> + size_t len = strlen(addr);
> unsigned char addr_len = 0;
> unsigned char p[10];
>
> @@ -546,7 +547,8 @@ gboolean sms_encode_address_field(const struct sms_address *in, gboolean sc,
> unsigned char *gsm;
> unsigned char *r;
>
> - if (len > 11)
> + /* TP-OA's 10 octets transport 11 8-bit chars */
> + if (g_utf8_strlen(addr, strlen(addr)) > 11)
> return FALSE;
>
> gsm = convert_utf8_to_gsm(in->address, len, NULL, &written, 0);
> @@ -675,7 +677,11 @@ gboolean sms_decode_address_field(const unsigned char *pdu, int len,
> if (utf8 == NULL)
> return FALSE;
>
> - if (strlen(utf8) > 20) {
> + /*
> + * TP-OA's 10 octets transport 11 8-bit chars,
> + * which take 23 bytes in unicode.
> + */
> + if (strlen(utf8) > 23) {
22, not 23.
> g_free(utf8);
> return FALSE;
> }
> diff --git a/src/smsutil.h b/src/smsutil.h
> index b1001f8..d252810 100644
> --- a/src/smsutil.h
> +++ b/src/smsutil.h
> @@ -220,7 +220,11 @@ enum cbs_geo_scope {
> struct sms_address {
> enum sms_number_type number_type;
> enum sms_numbering_plan numbering_plan;
> - char address[21]; /* Max 20 in semi-octet, 11 in alnum */
> + /*
> + * An alphanum TP-OA is 10 7-bit coded octets, which can carry
> + * 11 8-bit characters. Those converted to UTF-8 take 23 bytes.
22 bytes + null terminator.
> + */
> + char address[23];
> };
>
> struct sms_scts {
>
Regards,
-Denis
next prev parent reply other threads:[~2015-02-13 15:13 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-02-13 12:23 [PATCH 0/2] SMS-DELIVER TP-OA Alphanum decoding and encoding fix Tommi Kenakkala
2015-02-13 12:23 ` [PATCH 1/2] sms: " Tommi Kenakkala
2015-02-13 15:13 ` Denis Kenzior [this message]
2015-02-13 12:23 ` [PATCH 2/2] unit: SMS-DELIVER decoding/encoding test for long alphanum address Tommi Kenakkala
-- strict thread matches above, loose matches on Subject: below --
2015-02-13 9:49 [PATCH 1/2] sms: SMS-DELIVER TP-OA Alphanum decoding and encoding fix Tommi Kenakkala
2015-02-12 15:09 [PATCH 0/2] SMS-DELIVER Alphanum TP-OA encoding/decoding fix Tommi Kenakkala
2015-02-12 15:09 ` [PATCH 1/2] sms: SMS-DELIVER TP-OA Alphanum decoding and encoding fix Tommi Kenakkala
2015-02-12 18:59 ` Denis Kenzior
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=54DE148A.9090407@gmail.com \
--to=denkenz@gmail.com \
--cc=ofono@ofono.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox