Merge pull request #25 from khaledhosny/invalid-base128

Reject UIntBase128 with leading zeros
This commit is contained in:
rsheeter
2015-06-29 15:30:13 -04:00
+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();