diff options
author | Denis Kenzior <denkenz@gmail.com> | 2009-07-07 13:49:32 -0500 |
---|---|---|
committer | Denis Kenzior <denkenz@gmail.com> | 2009-07-07 14:33:59 -0500 |
commit | 5f04cb1c3ec33b158bb5cea550a41d90415761a2 (patch) | |
tree | f4b24c7a3197a157747e918f4e97d79c7ea78851 /src/util.c | |
parent | 35f7c4b06893fc49599d921cf0340accae41afba (diff) | |
download | ofono-5f04cb1c3ec33b158bb5cea550a41d90415761a2.tar.bz2 |
Fix length check for valid UCS2 starting with 0xff
Diffstat (limited to 'src/util.c')
-rw-r--r-- | src/util.c | 9 |
1 files changed, 8 insertions, 1 deletions
@@ -720,8 +720,15 @@ char *sim_string_to_utf8(const unsigned char *buffer, int length) switch (buffer[0]) { case 0x80: + if (((length - 1) % 2) == 1) { + if (buffer[length - 1] != 0xff) + return NULL; + + length = length - 1; + } + for (i = 1; i < length; i += 2) - if (buffer[i] == 0xff) + if (buffer[i] == 0xff && buffer[i + 1] == 0xff) break; return g_convert(buffer + 1, i - 1, |