~ chicken-core (master) 1901d975c0835e396c650a3da4c5cdfb5c7a3daf
commit 1901d975c0835e396c650a3da4c5cdfb5c7a3daf
Author: felix <felix@call-with-current-continuation.org>
AuthorDate: Mon May 18 12:31:41 2026 +0200
Commit: felix <felix@call-with-current-continuation.org>
CommitDate: Mon May 18 12:31:41 2026 +0200
add explicit check for continuation bytes when validating utf8
diff --git a/utf.c b/utf.c
index 294a8ae9..5672b6ed 100644
--- a/utf.c
+++ b/utf.c
@@ -3521,6 +3521,7 @@ C_regparm C_word C_utf_validate(C_word bv, C_word blen, C_word start, C_word end
unsigned char *s = C_c_string(bv) + C_unfix(start), *s2;
int len = C_unfix(end) - C_unfix(start);
while (len > 0) {
+ if(*s >= 0x80 && *s <= 0xbf) return C_SCHEME_FALSE;
if(lengths[*s >> 3] > len) return C_SCHEME_FALSE;
s2 = utf8_decode(s, &c, &e);
if(e) return C_SCHEME_FALSE;
Trap