diff options
author | Mark Wielaard <mark@klomp.org> | 2021-12-18 02:01:37 +0100 |
---|---|---|
committer | Mark Wielaard <mark@klomp.org> | 2021-12-18 02:23:44 +0100 |
commit | b16ff8198f91714048faaaed2a9b4e6801293226 (patch) | |
tree | 59da18ee5d2599434dc0319b75890fa7689b353a /libelf | |
parent | cdf407ef36378ba623c97f9c5c454666f45771fd (diff) | |
download | elfutils-b16ff8198f91714048faaaed2a9b4e6801293226.tar.gz |
libdwfl: Make sure note data is properly aligned.
In dwfl_segment_report_module the note data might not be properly
aligned. Check that it is before accessing the data directly.
Otherwise convert data so it is properly aligned.
Also fix NOTE_ALIGN4 and NOTE_ALIGN8 to work correctly with long
types.
Signed-off-by: Mark Wielaard <mark@klomp.org>
Diffstat (limited to 'libelf')
-rw-r--r-- | libelf/ChangeLog | 5 | ||||
-rw-r--r-- | libelf/libelfP.h | 4 |
2 files changed, 7 insertions, 2 deletions
diff --git a/libelf/ChangeLog b/libelf/ChangeLog index 96059eff..617d97a5 100644 --- a/libelf/ChangeLog +++ b/libelf/ChangeLog @@ -1,3 +1,8 @@ +2021-12-16 Mark Wielaard <mark@klomp.org> + + * libelfP.h (NOTE_ALIGN4): And with negative unsigned long. + (NOTE_ALIGN8): Likewise. + 2021-12-15 Mark Wielaard <mark@klomp.org> * elf_begin.c (get_shnum): Use offsetof to get field of unaligned diff --git a/libelf/libelfP.h b/libelf/libelfP.h index fc1aebec..2c6995bb 100644 --- a/libelf/libelfP.h +++ b/libelf/libelfP.h @@ -603,10 +603,10 @@ extern void __libelf_reset_rawdata (Elf_Scn *scn, void *buf, size_t size, /* Align offset to 4 bytes as needed for note name and descriptor data. This is almost always used, except for GNU Property notes, which use 8 byte padding... */ -#define NOTE_ALIGN4(n) (((n) + 3) & -4U) +#define NOTE_ALIGN4(n) (((n) + 3) & -4UL) /* Special note padding rule for GNU Property notes. */ -#define NOTE_ALIGN8(n) (((n) + 7) & -8U) +#define NOTE_ALIGN8(n) (((n) + 7) & -8UL) /* Convenience macro. */ #define INVALID_NDX(ndx, type, data) \ |