mirror of
https://github.com/hrydgard/ppsspp.git
synced 2025-04-02 11:01:50 -04:00
Debugger: Try harder to validate UTF-8.
When sending this in the websocket debugger, it needs to be valid utf-8 or it will cause clients to abort the connection. We want to reject invalid utf-8 anyway.
This commit is contained in:
parent
f987c715aa
commit
56bcf04c49
1 changed files with 10 additions and 0 deletions
|
@ -64,13 +64,23 @@ bool IsLikelyStringAt(uint32_t addr) {
|
|||
if (utf.end())
|
||||
return false;
|
||||
|
||||
char verify[4];
|
||||
while (!utf.end()) {
|
||||
if (utf.invalid())
|
||||
return false;
|
||||
|
||||
int pos = utf.byteIndex();
|
||||
uint32_t c = utf.next();
|
||||
int len = UTF8::encode(verify, c);
|
||||
// Our decoder is a bit lax, so let's verify this is a normal encoding.
|
||||
// This prevents us from trying to output invalid encodings in the debugger.
|
||||
if (memcmp(p + pos, verify, len) != 0 || pos + len != utf.byteIndex())
|
||||
return false;
|
||||
|
||||
if (c < ARRAY_SIZE(validControl) && !validControl[c])
|
||||
return false;
|
||||
if (c > 0x0010FFFF)
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
|
|
Loading…
Add table
Reference in a new issue