Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1456)

Unified Diff: courgette/disassembler.h

Issue 1031513002: Robust ELF header parsing. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Replace uint32_t with Elf32_Off and add CHECK in ReduceLength Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | courgette/disassembler.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: courgette/disassembler.h
diff --git a/courgette/disassembler.h b/courgette/disassembler.h
index 77abd41966e5ddf032538a1e64854fa1c5bf073e..0154ec4bab1d5a6f9652c9989e5d5ab407458d48 100644
--- a/courgette/disassembler.h
+++ b/courgette/disassembler.h
@@ -54,6 +54,11 @@ class Disassembler {
bool Good();
bool Bad(const char *reason);
+ // Returns true if the array lies within our memory region.
+ bool IsArrayInBounds(size_t offset, size_t elements, size_t element_size) {
+ return offset <= length() && elements <= (length() - offset) / element_size;
+ }
+
// These helper functions avoid the need for casts in the main code.
uint16 ReadU16(const uint8* address, size_t offset) {
return *reinterpret_cast<const uint16*>(address + offset);
« no previous file with comments | « no previous file | courgette/disassembler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698