mirror of
https://github.com/JakeHillion/drgn.git
synced 2024-12-26 02:25:36 +00:00
dwarfindex: don't check that strp is null-terminated
If we make sure .debug_str is null-terminated, we just need to make sure strp is not out of bounds.
This commit is contained in:
parent
b45e930336
commit
7599691dd1
@ -881,10 +881,7 @@ sibling_ref:
|
||||
return -1;
|
||||
}
|
||||
name = &debug_str_buffer[strp];
|
||||
if (!memchr(name, 0, debug_str_end - name)) {
|
||||
PyErr_SetNone(PyExc_EOFError);
|
||||
return -1;
|
||||
}
|
||||
__builtin_prefetch(name);
|
||||
continue;
|
||||
case DW_FORM_string:
|
||||
if (*ptr >= end) {
|
||||
@ -1079,6 +1076,7 @@ static int DwarfIndex_init(DwarfIndex *self, PyObject *args, PyObject *kwds)
|
||||
}
|
||||
|
||||
for (i = 0; i < self->num_files; i++) {
|
||||
const struct section *debug_str;
|
||||
PyObject *path;
|
||||
size_t j;
|
||||
|
||||
@ -1107,6 +1105,14 @@ static int DwarfIndex_init(DwarfIndex *self, PyObject *args, PyObject *kwds)
|
||||
return -1;
|
||||
}
|
||||
|
||||
debug_str = &self->files[i].debug_sections[DEBUG_STR];
|
||||
if (debug_str->size == 0 ||
|
||||
debug_str->buffer[debug_str->size - 1] != '\0') {
|
||||
PyErr_SetString(DwarfFormatError,
|
||||
".debug_str is not null terminated");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (read_cus(self, &self->files[i]) == -1)
|
||||
return -1;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user