[PATCH 08/10] dbghelp{dwarf}: Validate that a string is in the section boundary before using it
Eric Pouech
eric.pouech at gmail.com
Sat Sep 11 03:59:30 CDT 2021
Signed-off-by: Eric Pouech <eric.pouech at gmail.com>
---
dlls/dbghelp/dwarf.c | 16 +++++++++++++---
1 file changed, 13 insertions(+), 3 deletions(-)
diff --git a/dlls/dbghelp/dwarf.c b/dlls/dbghelp/dwarf.c
index 3988f2b3d44..1483bd282cb 100644
--- a/dlls/dbghelp/dwarf.c
+++ b/dlls/dbghelp/dwarf.c
@@ -601,9 +601,19 @@ static BOOL dwarf2_fill_attr(const dwarf2_parse_context_t* ctx,
break;
case DW_FORM_strp:
- attr->u.string = (const char*)ctx->sections[section_string].address +
- dwarf2_get_addr(data, ctx->head.offset_size);
- TRACE("strp<%s>\n", debugstr_a(attr->u.string));
+ {
+ ULONG_PTR ofs = dwarf2_get_addr(data, ctx->head.offset_size);
+ if (ofs >= ctx->sections[section_string].size)
+ {
+ ERR("Out of bounds string offset (%08lx)\n", ofs);
+ attr->u.string = "<<outofbounds-strp>>";
+ }
+ else
+ {
+ attr->u.string = (const char*)ctx->sections[section_string].address + ofs;
+ TRACE("strp<%s>\n", debugstr_a(attr->u.string));
+ }
+ }
break;
case DW_FORM_block:
More information about the wine-devel
mailing list