Reject UIntBase128 with leading zeros

Fixes #23.
This commit is contained in:
Khaled Hosny
2015-06-25 06:53:21 +02:00
parent 2855ee7b8b
commit f43ad22271
+4
View File
@@ -98,6 +98,10 @@ bool ReadBase128(Buffer* buf, uint32_t* value) {
if (!buf->ReadU8(&code)) {
return FONT_COMPRESSION_FAILURE();
}
// Leading zeros are invalid.
if (i == 0 && code == 0x80) {
return FONT_COMPRESSION_FAILURE();
}
// If any of the top seven bits are set then we're about to overflow.
if (result & 0xfe000000) {
return FONT_COMPRESSION_FAILURE();