summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2014-11-07 16:34:00 +0100
committerLennart Poettering <lennart@poettering.net>2014-11-07 16:36:14 +0100
commit144b3d9e093dd9310cd9590bec039dc43a7e2ad6 (patch)
treece554464d0a949d46dd5e8a8788eff93e195498c
parentf9aa5413807e163df49171793eb93a230cd7b955 (diff)
utf8: when looking at the next unichar, honour the size parameter, in utf8_is_printable_newline()
-rw-r--r--src/shared/utf8.c8
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;