mirror of https://github.com/mpv-player/mpv
common: validate parsed unicode codepoints value
Fixes UB when converting out of expected range values. Found by OSS-Fuzz.
This commit is contained in:
parent
758019bf92
commit
5534e0e1d9
|
@ -273,7 +273,7 @@ static bool mp_parse_escape(void *talloc_ctx, bstr *dst, bstr *code)
|
||||||
if (code->start[0] == 'u' && code->len >= 5) {
|
if (code->start[0] == 'u' && code->len >= 5) {
|
||||||
bstr num = bstr_splice(*code, 1, 5);
|
bstr num = bstr_splice(*code, 1, 5);
|
||||||
uint32_t c = bstrtoll(num, &num, 16);
|
uint32_t c = bstrtoll(num, &num, 16);
|
||||||
if (num.len)
|
if (num.len || c > 0x10FFFF)
|
||||||
return false;
|
return false;
|
||||||
if (c >= 0xd800 && c <= 0xdbff) {
|
if (c >= 0xd800 && c <= 0xdbff) {
|
||||||
if (code->len < 5 + 6 // udddd + \udddd
|
if (code->len < 5 + 6 // udddd + \udddd
|
||||||
|
|
Loading…
Reference in New Issue