diff options
author | Mark Wielaard <mjw@redhat.com> | 2014-11-23 15:27:23 +0100 |
---|---|---|
committer | Mark Wielaard <mjw@redhat.com> | 2014-11-26 20:21:44 +0100 |
commit | 51abc748db839f35589611f7129168728a1ebcc0 (patch) | |
tree | b8d186328019ec459c46d68426dceae5a5e836e3 | |
parent | 9644aaff5f2872061b1a09afac3f2d0d4ad9a1c2 (diff) | |
download | elfutils-51abc748db839f35589611f7129168728a1ebcc0.tar.gz |
libelf: Copy over any leftover data from src to dest in elf_cvt_note.
If any data is left then the data is likely part of the truncated note
name/desc. This probably means the note is corrupted, but it is better
to have the actual data in dest instead of random uninitialized memory.
Signed-off-by: Mark Wielaard <mjw@redhat.com>
-rw-r--r-- | libelf/ChangeLog | 5 | ||||
-rw-r--r-- | libelf/note_xlate.h | 7 |
2 files changed, 11 insertions, 1 deletions
diff --git a/libelf/ChangeLog b/libelf/ChangeLog index b21714e3..8a115631 100644 --- a/libelf/ChangeLog +++ b/libelf/ChangeLog @@ -1,3 +1,8 @@ +2014-11-23 Mark Wielaard <mjw@redhat.com> + + * note_xlate.h (elf_cvt_note): Copy over any leftover data if + src != dest. The data is probably part of truncated name/desc. + 2014-11-22 Mark Wielaard <mjw@redhat.com> * elf_getphdrnum.c (elf_getphdrnum): Sanity check the diff --git a/libelf/note_xlate.h b/libelf/note_xlate.h index 8187e881..62c6f63d 100644 --- a/libelf/note_xlate.h +++ b/libelf/note_xlate.h @@ -1,5 +1,5 @@ /* Conversion functions for notes. - Copyright (C) 2007, 2009 Red Hat, Inc. + Copyright (C) 2007, 2009, 2014 Red Hat, Inc. This file is part of elfutils. This file is free software; you can redistribute it and/or modify @@ -56,4 +56,9 @@ elf_cvt_note (void *dest, const void *src, size_t len, int encode) src += namesz + descsz; dest += namesz + descsz; } + + /* Copy opver any leftover data unconcerted. Probably part of + truncated name/desc data. */ + if (unlikely (len > 0) && src != dest) + memcpy (dest, src, len); } |