aboutsummaryrefslogtreecommitdiff
path: root/liberty.c
diff options
context:
space:
mode:
authorPřemysl Eric Janouch <p@janouch.name>2020-10-21 04:52:24 +0200
committerPřemysl Eric Janouch <p@janouch.name>2020-10-21 05:08:59 +0200
commitb08cf6c29f94373823a910e015c62d437f83dbfd (patch)
tree23a5fc7979f05d625b42d921b27accd0f6434094 /liberty.c
parent69101eb1554ad2fca6de30cdbaccac076210d7e3 (diff)
downloadliberty-b08cf6c29f94373823a910e015c62d437f83dbfd.tar.gz
liberty-b08cf6c29f94373823a910e015c62d437f83dbfd.tar.xz
liberty-b08cf6c29f94373823a910e015c62d437f83dbfd.zip
Reject overlong UTF-8 sequences
Diffstat (limited to 'liberty.c')
-rw-r--r--liberty.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/liberty.c b/liberty.c
index 3aadc29..c0b6bb4 100644
--- a/liberty.c
+++ b/liberty.c
@@ -2753,6 +2753,11 @@ utf8_decode (const char **s, size_t len)
// Check the rest of the sequence
uint32_t cp = *p++ & ~mask;
+
+ // Overlong sequence (possibly MUTF-8, not supported)
+ if (!cp && sequence_len)
+ return -1;
+
while (sequence_len && --sequence_len)
{
if (p == end)