X-Git-Url: https://git.saurik.com/apple/dyld.git/blobdiff_plain/412ebb8e3cc35d457058c31310d89ef96b7c416d..64db26dd8d8b4bbcbca664ab56354d7c038f0e6b:/launch-cache/MachOTrie.hpp?ds=sidebyside diff --git a/launch-cache/MachOTrie.hpp b/launch-cache/MachOTrie.hpp index 05a8e07..7720b11 100644 --- a/launch-cache/MachOTrie.hpp +++ b/launch-cache/MachOTrie.hpp @@ -25,6 +25,7 @@ #define __MACH_O_TRIE__ #include +#include #include "MachOFileAbstraction.hpp" @@ -245,12 +246,19 @@ inline uint64_t read_uleb128(const uint8_t*& p, const uint8_t* end) { int bit = 0; do { if (p == end) +#if __EXCEPTIONS throw "malformed uleb128 extends beyond trie"; - +#else + return result; +#endif uint64_t slice = *p & 0x7f; if (bit >= 64 || slice << bit >> bit != slice) +#if __EXCEPTIONS throw "uleb128 too big for 64-bits"; +#else + return result; +#endif else { result |= (slice << bit); bit += 7; @@ -321,7 +329,11 @@ static inline void processExportNode(const uint8_t* const start, const uint8_t* std::vector& output) { if ( p >= end ) +#if __EXCEPTIONS throw "malformed trie, node past end"; +#else + return; +#endif const uint8_t terminalSize = read_uleb128(p, end); const uint8_t* children = p + terminalSize; if ( terminalSize != 0 ) {