aboutsummaryrefslogtreecommitdiff
path: root/liberty.c
diff options
context:
space:
mode:
authorPřemysl Eric Janouch <p@janouch.name>2020-10-24 19:06:41 +0200
committerPřemysl Eric Janouch <p@janouch.name>2020-10-24 19:09:09 +0200
commit96397778144722f7983774e9fc88521f4d36d3c7 (patch)
tree897544359c20130582fab849a0f22a0983dd84ca /liberty.c
parent929229a1d7f64ce345157443525dc2410e5e2381 (diff)
downloadliberty-96397778144722f7983774e9fc88521f4d36d3c7.tar.gz
liberty-96397778144722f7983774e9fc88521f4d36d3c7.tar.xz
liberty-96397778144722f7983774e9fc88521f4d36d3c7.zip
Fix validation of overlong UTF-8
It was too strict and Egyptian dicks didn't want to pass, so we'll do it half-arsedly for a subset.
Diffstat (limited to 'liberty.c')
-rw-r--r--liberty.c8
1 files changed, 2 insertions, 6 deletions
diff --git a/liberty.c b/liberty.c
index 1695fd3..9705081 100644
--- a/liberty.c
+++ b/liberty.c
@@ -2748,16 +2748,12 @@ utf8_decode (const char **s, size_t len)
}
// In the middle of a character
- if (sequence_len == 1)
+ // or an overlong sequence (subset, possibly MUTF-8, not supported)
+ if (sequence_len == 1 || *p == 0xC0 || *p == 0xC1)
return -1;
// 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)