From: jasper Date: Wed, 27 Oct 2021 21:21:35 +0000 (+0000) Subject: extend checks of ensuring there's valid CTF data before attempting to use it. X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=ece49713fc531e06bbb0487c48d217b1695add8f;p=openbsd extend checks of ensuring there's valid CTF data before attempting to use it. --- diff --git a/sys/ddb/db_ctf.c b/sys/ddb/db_ctf.c index 7b844f87756..ddb7ae8f777 100644 --- a/sys/ddb/db_ctf.c +++ b/sys/ddb/db_ctf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: db_ctf.c,v 1.30 2020/10/15 03:14:00 deraadt Exp $ */ +/* $OpenBSD: db_ctf.c,v 1.31 2021/10/27 21:21:35 jasper Exp $ */ /* * Copyright (c) 2016-2017 Martin Pieuchot @@ -248,13 +248,15 @@ const struct ctf_type * db_ctf_type_by_symbol(Elf_Sym *st) { Elf_Sym *symp; - uint32_t objtoff = db_ctf.cth->cth_objtoff; + uint32_t objtoff; uint16_t *dsp; size_t idx = 0; if (!db_ctf.ctf_found || st == NULL) return NULL; + objtoff = db_ctf.cth->cth_objtoff; + while (objtoff < db_ctf.cth->cth_funcoff) { dsp = (uint16_t *)(db_ctf.data + objtoff); @@ -493,6 +495,9 @@ db_ctf_off2name(uint32_t offset) { const char *name; + if (!db_ctf.ctf_found) + return NULL; + if (CTF_NAME_STID(offset) != CTF_STRTAB_0) return "external";