systemd/0003-utf8-when-looking-at-the-next-unichar-honour-the-siz.patch

30 lines
1.1 KiB
Diff
Raw Normal View History

Based on 144b3d9e093dd9310cd9590bec039dc43a7e2ad6 Mon Sep 17 00:00:00 2001
From: Lennart Poettering <lennart@poettering.net>
Date: Fri, 7 Nov 2014 16:34:00 +0100
Subject: [PATCH] utf8: when looking at the next unichar, honour the size
parameter, in utf8_is_printable_newline()
---
src/shared/utf8.c | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
--- src/shared/utf8.c
+++ src/shared/utf8.c 2014-11-10 14:20:28.094539264 +0000
@@ -143,9 +143,14 @@ bool utf8_is_printable_newline(const cha
for (p = (const uint8_t*) str; length;) {
int encoded_len = utf8_encoded_valid_unichar((const char *)p);
- int val = utf8_encoded_to_unichar((const char*)p);
+ int val;
- if (encoded_len < 0 || val < 0 || is_unicode_control(val) ||
+ if (encoded_len < 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;