ofono.lists.linux.dev archive mirror
 help / color / mirror / Atom feed
From: Denis Kenzior <denkenz@gmail.com>
To: ofono@ofono.org
Subject: Re: [PATCH v3 1/3] simutil: add validate_utf8_tlv
Date: Tue, 19 Jan 2021 10:04:54 -0600	[thread overview]
Message-ID: <01bf6f8f-83fd-b1d4-bf3f-76d468eadecf@gmail.com> (raw)
In-Reply-To: <20210116192107.18568-2-geomatsi@gmail.com>

[-- Attachment #1: Type: text/plain, Size: 919 bytes --]

Hi Sergey,

On 1/16/21 1:21 PM, Sergey Matyukevich wrote:
> Add helper to validate if TLV value is a valid UTF8 string.
> Note that both null-terminated and non null-terminated UTF8
> strings are considered valid.
> ---
>   src/simutil.c | 14 ++++++++++++++
>   src/simutil.h |  1 +
>   2 files changed, 15 insertions(+)
> 

<snip>

> +gboolean validate_utf8_tlv(const unsigned char *tlv)
> +{
> +	int len = tlv[1];
> +
> +	if (len == 0)
> +		return FALSE;
> +
> +	/* support both null-termiated and non null-terminated UTF8 TLV value */

I tweaked this comment to fix the typo here and make fit to 80 chars

> +	if (tlv[len + 1] == '\0')
> +		len -= 1;
> +
> +	return g_utf8_validate_len((const char *)tlv + 2, len, NULL);
> +}
> +
>   static char *sim_network_name_parse(const unsigned char *buffer, int length,
>   					gboolean *add_ci)
>   {

Applied, thanks.

Regards,
-Denis

  reply	other threads:[~2021-01-19 16:04 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-01-16 19:21 [PATCH v3 0/3] sim: validate IMS private identity Sergey Matyukevich
2021-01-16 19:21 ` [PATCH v3 1/3] simutil: add validate_utf8_tlv Sergey Matyukevich
2021-01-19 16:04   ` Denis Kenzior [this message]
2021-01-16 19:21 ` [PATCH v3 2/3] sim: validate IMS private identity Sergey Matyukevich
2021-01-19 16:05   ` Denis Kenzior
2021-01-16 19:21 ` [PATCH v3 3/3] unit: add validate_utf8_tlv tests Sergey Matyukevich

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=01bf6f8f-83fd-b1d4-bf3f-76d468eadecf@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;
as well as URLs for NNTP newsgroup(s).