mirror of
https://github.com/vee1e/flatbuffers.git
synced 2026-09-04 11:17:38 +00:00
fixes for annotator
This commit is contained in:
parent
7165219535
commit
0bbfd4b2e3
1 changed files with 11 additions and 3 deletions
|
|
@ -61,6 +61,14 @@ static bool IsNonZeroRegion(const uint64_t offset, const uint64_t length,
|
|||
return false;
|
||||
}
|
||||
|
||||
static bool IsPrintableRegion(const uint64_t offset, const uint64_t length,
|
||||
const uint8_t *const binary) {
|
||||
for (uint64_t i = offset; i < offset + length; ++i) {
|
||||
if (!isprint(binary[i])) { return false; }
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
static BinarySection GenerateMissingSection(const uint64_t offset,
|
||||
const uint64_t length,
|
||||
const uint8_t *const binary) {
|
||||
|
|
@ -168,7 +176,7 @@ uint64_t BinaryAnnotator::BuildHeader(const uint64_t header_offset) {
|
|||
offset += sizeof(uint32_t);
|
||||
|
||||
if (IsValidRead(offset, flatbuffers::kFileIdentifierLength) &&
|
||||
IsNonZeroRegion(offset, flatbuffers::kFileIdentifierLength, binary_)) {
|
||||
IsPrintableRegion(offset, flatbuffers::kFileIdentifierLength, binary_)) {
|
||||
BinaryRegionComment comment;
|
||||
comment.type = BinaryRegionCommentType::FileIdentifier;
|
||||
// Check if the file identifier region has non-zero data, and assume its
|
||||
|
|
@ -1404,8 +1412,8 @@ bool BinaryAnnotator::ContainsSection(const uint64_t offset) {
|
|||
--it;
|
||||
|
||||
// And check that if the offset is covered by the section.
|
||||
return offset >= it->first && offset <= it->second.regions.back().offset +
|
||||
it->second.regions.back().length;
|
||||
return offset >= it->first && offset < it->second.regions.back().offset +
|
||||
it->second.regions.back().length;
|
||||
}
|
||||
|
||||
} // namespace flatbuffers
|
||||
Loading…
Add table
Add a link
Reference in a new issue