common: validate parsed unicode codepoints value

Fixes UB when converting out of expected range values.

Found by OSS-Fuzz.
This commit is contained in:
Kacper Michajłow committed 2024-06-23 02:33:04 +02:00
1 parent 758019bf92
commit 5534e0e1d9
1 file changed
+1 -1
+1 -1
View File
@@ -273,7 +273,7 @@ static bool mp_parse_escape(void *talloc_ctx, bstr *dst, bstr *code)
if (code->start[0] == 'u' && code->len >= 5) {
bstr num = bstr_splice(*code, 1, 5);
uint32_t c = bstrtoll(num, &num, 16);
if (num.len)
if (num.len || c > 0x10FFFF)
return false;
if (c >= 0xd800 && c <= 0xdbff) {
if (code->len < 5 + 6 // udddd + \udddd