From: Wolfgang Bumiller Date: Sat, 22 Dec 2012 21:31:10 +0000 (+0100) Subject: u8_analyze: return false on any invalid character, we do not allow invalid/overlong... X-Git-Tag: before-library~545 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=aec2284f4597ea39375fc2c9ac4220a0abd495a8;p=xonotic%2Fgmqcc.git u8_analyze: return false on any invalid character, we do not allow invalid/overlong characters in code at all --- diff --git a/utf8lib.c b/utf8lib.c index 3c4749b..b26f2f1 100644 --- a/utf8lib.c +++ b/utf8lib.c @@ -48,7 +48,7 @@ static bool u8_analyze(const char *_s, size_t *_start, size_t *_len, Uchar *_ch, Uchar ch; i = 0; -findchar: +/* findchar: */ while (i < _maxlen && s[i] && (bits = utf8_lengths[s[i]]) == 0) ++i; @@ -71,14 +71,20 @@ findchar: if ( (s[i+j] & 0xC0) != 0x80 ) { i += j; - goto findchar; + /* in gmqcc, invalid / overlong encodings are considered an error + * goto findchar; + */ + return false; } ch = (ch << 6) | (s[i+j] & 0x3F); } if (ch < utf8_range[bits] || ch >= 0x10FFFF) { - i += bits; - goto findchar; + /* same: error + * i += bits; + * goto findchar; + */ + return false; } if (_start)