diff options
author | comex | 2016-01-27 15:53:52 -0500 |
---|---|---|
committer | comex | 2016-01-27 15:53:52 -0500 |
commit | 92e01bb100212df6dea51859e3129fa13997f74e (patch) | |
tree | 6fefed10afb6ca19e2a37c12b524a86b50e0681c /lib/darwin/find-syms.c | |
parent | Update mconfig.py and fix the debug info option with multiple machines; updat... (diff) | |
download | substitute-92e01bb100212df6dea51859e3129fa13997f74e.tar.gz |
Fix incorrect handling if there is no local symbol info in the cache.
Diffstat (limited to 'lib/darwin/find-syms.c')
-rw-r--r-- | lib/darwin/find-syms.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/lib/darwin/find-syms.c b/lib/darwin/find-syms.c index d3524e2..1666f1c 100644 --- a/lib/darwin/find-syms.c +++ b/lib/darwin/find-syms.c @@ -39,7 +39,6 @@ static bool oscf_try_dir(const char *dir, const char *arch, if (memcmp(this_dch.uuid, dch->uuid, 16) || this_dch.localSymbolsSize != dch->localSymbolsSize /* just in case */) goto fail; - s_cur_shared_cache_fd = fd; struct dyld_cache_local_symbols_info *lsi = &s_cache_local_symbols_info; if (pread(fd, lsi, sizeof(*lsi), dch->localSymbolsOffset) != sizeof(*lsi)) goto fail; @@ -64,10 +63,12 @@ static bool oscf_try_dir(const char *dir, const char *arch, goto fail; } + s_cur_shared_cache_fd = fd; s_cache_local_symbols_entries = lses; return true; fail: + memset(lsi, 0, sizeof(*lsi)); close(fd); return false; } @@ -77,6 +78,8 @@ static void open_shared_cache_file_once() { const struct dyld_cache_header *dch = s_cur_shared_cache_hdr; if (memcmp(dch->magic, "dyld_v1 ", 8)) return; + if (dch->localSymbolsSize < sizeof(struct dyld_cache_local_symbols_info)) + return; const char *archp = &dch->magic[8]; while (*archp == ' ') archp++; |