basic/utf8: do not read past end of string when looking for a multi-byte character

Fixes https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=9341.
This commit is contained in:
Zbigniew Jędrzejewski-Szmek
2019-02-26 12:37:40 +01:00
parent 84319aa76e
commit 92e068b465
8 changed files with 42 additions and 26 deletions
+1 -1
View File
@@ -28,7 +28,7 @@ int encode_devnode_name(const char *str, char *str_enc, size_t len) {
for (i = 0, j = 0; str[i] != '\0'; i++) {
int seqlen;
seqlen = utf8_encoded_valid_unichar(&str[i]);
seqlen = utf8_encoded_valid_unichar(str + i, (size_t) -1);
if (seqlen > 1) {
if (len-j < (size_t)seqlen)