diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2012-07-10 17:56:53 -0700 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2012-07-10 17:56:53 -0700 |
commit | 3abd3dba424450401ca0bb34c043d0331f1c1abe (patch) | |
tree | ed7f53eff62907d5deb11de97c2a0d1056d394f4 | |
parent | 3c7bd9a7d294ed9f34e952fab792644c5caf6c18 (diff) | |
download | uemacs-3abd3dba424450401ca0bb34c043d0331f1c1abe.tar.gz |
utf8: make sure to honor the array length properly
Right now the input side can give partial utf8 input, and that showed
that we didn't properly handle that case.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r-- | utf8.c | 4 |
1 files changed, 2 insertions, 2 deletions
@@ -41,13 +41,13 @@ unsigned utf8_to_unicode(char *line, unsigned index, unsigned len, unicode_t *re /* Invalid? Do it as a single byte Latin1 */ if (bytes > 6) return 1; + if (bytes > len) + return 1; value = c & (mask-1); /* Ok, do the bytes */ for (i = 1; i < bytes; i++) { - if (i > len) - return 1; c = line[i]; if ((c & 0xc0) != 0x80) return 1; |