Hi, When adding data to existing sections in ELF files, libelf may corrupt those sections, i.e. overwrite the existing data if certain conditions are met. If an Elf_Scn structure has seen a call to elf_rawdata(scn) before but no call to elf_getdata(scn), scn->read_data flag is set, but not scn->data_list_rear. Thus, elf_newdata(scn) incorrectly detects a "new user added section" when really it is a section with live, valid data that will be overwritten by elf_update(), corrupting the section. This patch fixes this incorrect behaviour. Signed-off-by: Thilo Schulz --- libelf/elf_newdata.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libelf/elf_newdata.c b/libelf/elf_newdata.c index 90d1813..f90eb0a 100644 --- a/libelf/elf_newdata.c +++ b/libelf/elf_newdata.c @@ -64,7 +64,7 @@ elf_newdata (Elf_Scn *scn) rwlock_wrlock (scn->elf->lock); - if (scn->data_read && scn->data_list_rear == NULL) + if (scn->data_read && scn->data_list_rear == NULL && !scn->rawdata.s) { /* This means the section was created by the user and this is the first data. */ -- 1.7.10.4