mirror of
https://github.com/hrydgard/ppsspp.git
synced 2026-11-27 00:03:37 +01: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:
1 parent
f987c715aa
commit
56bcf04c49
1 file changed
+10
@@ -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;
|
||||
|
||||
Reference in new issue
Block a user