diff options
author | Lennart Poettering <lennart@poettering.net> | 2014-11-07 16:34:00 +0100 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2014-11-07 16:36:14 +0100 |
commit | 144b3d9e093dd9310cd9590bec039dc43a7e2ad6 (patch) | |
tree | ce554464d0a949d46dd5e8a8788eff93e195498c | |
parent | f9aa5413807e163df49171793eb93a230cd7b955 (diff) |
utf8: when looking at the next unichar, honour the size parameter, in utf8_is_printable_newline()
-rw-r--r-- | src/shared/utf8.c | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/src/shared/utf8.c b/src/shared/utf8.c index 9353559b76..8702ceb1b2 100644 --- a/src/shared/utf8.c +++ b/src/shared/utf8.c @@ -150,10 +150,12 @@ bool utf8_is_printable_newline(const char* str, size_t length, bool newline) { int encoded_len, val; encoded_len = utf8_encoded_valid_unichar((const char *) p); - val = utf8_encoded_to_unichar((const char*) p); - if (encoded_len < 0 || - val < 0 || + (size_t) encoded_len > length) + return false; + + val = utf8_encoded_to_unichar((const char*) p); + if (val < 0 || is_unicode_control(val) || (!newline && val == '\n')) return false; |