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
_______________________________________________
ofono mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to