summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2014-11-07 16:34:00 +0100
committerAnthony G. Basile <blueness@gentoo.org>2014-11-14 17:26:13 -0500
commite2c392176c9816ad3757e9f7eb575702c0b31392 (patch)
treed14f8ae7f1038680d5d47c1798891f0eeaecacf6 /src
parent71f9ca7cef18887efc189277b8e78b88ff1d4ea6 (diff)
utf8: when looking at the next unichar, honour the size parameter, in utf8_is_printable_newline()
Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
Diffstat (limited to 'src')
-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 403166d7f9..75ed7caee3 100644
--- a/src/shared/utf8.c
+++ b/src/shared/utf8.c
@@ -148,10 +148,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;