diff options
| author | Mark Wielaard <[email protected]> | 2015-01-21 23:56:43 +0100 |
|---|---|---|
| committer | Mark Wielaard <[email protected]> | 2015-02-06 22:29:34 +0100 |
| commit | 710ca87893bef2fa186265a8624a6402509ba1f3 (patch) | |
| tree | 5078651c4dcc4fe7bf03caa475abe95eeeb898ab /libelf | |
| parent | b543cdd95a0f9dfc33c862585f108a7a19728a10 (diff) | |
libelf: elf_strptr should use datalist when data has been added to section.
elf_strptr always used the rawdata when available. But when data has been
added to the section it should find the correct buffer in the datalist.
Adds a large testcase that checks various ways of adding and extracting
strings from a section.
Signed-off-by: Mark Wielaard <[email protected]>
Diffstat (limited to 'libelf')
| -rw-r--r-- | libelf/ChangeLog | 5 | ||||
| -rw-r--r-- | libelf/elf_strptr.c | 18 |
2 files changed, 17 insertions, 6 deletions
diff --git a/libelf/ChangeLog b/libelf/ChangeLog index 15485029..42d2f0ff 100644 --- a/libelf/ChangeLog +++ b/libelf/ChangeLog @@ -1,3 +1,8 @@ +2015-01-21 Mark Wielaard <[email protected]> + + * elf_strptr.c (elf_strptr): Check data_list_rear == NULL instead + of rawdata_base != NULL before using rawdata directly. + 2015-01-20 Mark Wielaard <[email protected]> * libelfP.h (__elf_strptr_internal): New function declaration. diff --git a/libelf/elf_strptr.c b/libelf/elf_strptr.c index f30a06fc..62936a0f 100644 --- a/libelf/elf_strptr.c +++ b/libelf/elf_strptr.c @@ -131,12 +131,18 @@ elf_strptr (elf, idx, offset) goto out; } - if (likely (strscn->rawdata_base != NULL)) - // XXX Is this correct if a file is read and then new data is added - // XXX to the string section? Likely needs to check offset against - // XXX size of rawdata_base buffer and then iterate over rest of the - // XXX list. - result = &strscn->rawdata_base[offset]; + if (likely (strscn->data_list_rear == NULL)) + { + // XXX The above is currently correct since elf_newdata will + // make sure to convert the rawdata into the datalist if + // necessary. But it would be more efficient to keep the rawdata + // unconverted and only then iterate over the rest of the (newly + // added data) list. Note that when the ELF file is mmapped + // rawdata_base can be set while rawdata.d hasn't been + // initialized yet (when data_read is zero). So we cannot just + // look at the rawdata.d.d_size. + result = &strscn->rawdata_base[offset]; + } else { /* This is a file which is currently created. Use the list of |
