diff options
author | Mark Wielaard <mark@klomp.org> | 2019-01-30 00:04:11 +0100 |
---|---|---|
committer | Mark Wielaard <mark@klomp.org> | 2019-01-30 00:04:11 +0100 |
commit | cd7ded3df43f655af945c869976401a602e46fcd (patch) | |
tree | 34fd5ed50250109c2f78ade2dc494ed8fe4a8bfb /libebl | |
parent | 14ec4824632be7a35afb422f8205773a2bd579d8 (diff) | |
download | elfutils-cd7ded3df43f655af945c869976401a602e46fcd.tar.gz |
libebl: Check GNU property note data padding fits inside note.
The GNU property note data is padded. Make sure the extra padding
still fits in the note description.
https://sourceware.org/bugzilla/show_bug.cgi?id=24075
Signed-off-by: Mark Wielaard <mark@klomp.org>
Diffstat (limited to 'libebl')
-rw-r--r-- | libebl/ChangeLog | 5 | ||||
-rw-r--r-- | libebl/eblobjnote.c | 17 |
2 files changed, 14 insertions, 8 deletions
diff --git a/libebl/ChangeLog b/libebl/ChangeLog index 9cdf8995..acc68919 100644 --- a/libebl/ChangeLog +++ b/libebl/ChangeLog @@ -1,3 +1,8 @@ +2019-01-29 Mark Wielaard <mark@klomp.org> + + * eblobjnote.c (ebl_object_note): Check pr_datasz padding doesn't + overflow descsz. + 2019-01-16 Mark Wielaard <mark@klomp.org> * libebl.h (ebl_core_note): Add desc as argument. diff --git a/libebl/eblobjnote.c b/libebl/eblobjnote.c index 9094715c..f7ac915c 100644 --- a/libebl/eblobjnote.c +++ b/libebl/eblobjnote.c @@ -496,16 +496,17 @@ ebl_object_note (Ebl *ebl, uint32_t namesz, const char *name, uint32_t type, printf ("%02" PRIx8 "\n", (uint8_t) desc[i]); } } + if (elfclass == ELFCLASS32) - { - desc += NOTE_ALIGN4 (prop.pr_datasz); - descsz -= NOTE_ALIGN4 (prop.pr_datasz); - } + prop.pr_datasz = NOTE_ALIGN4 (prop.pr_datasz); else - { - desc += NOTE_ALIGN8 (prop.pr_datasz); - descsz -= NOTE_ALIGN8 (prop.pr_datasz); - } + prop.pr_datasz = NOTE_ALIGN8 (prop.pr_datasz); + + desc += prop.pr_datasz; + if (descsz > prop.pr_datasz) + descsz -= prop.pr_datasz; + else + descsz = 0; } } break; |