diff options
author | marcel <marcel@FreeBSD.org> | 2014-10-22 01:04:16 +0000 |
---|---|---|
committer | marcel <marcel@FreeBSD.org> | 2014-10-22 01:04:16 +0000 |
commit | 3d0d095b21161a49cf5e933443ce7d3d31f8416c (patch) | |
tree | 659c66dbb1753897af638b2f467dc66c97f9978d /contrib/elftoolchain | |
parent | 76382aeb894a5ee6019058513321db33e7aa8c58 (diff) | |
download | FreeBSD-src-3d0d095b21161a49cf5e933443ce7d3d31f8416c.zip FreeBSD-src-3d0d095b21161a49cf5e933443ce7d3d31f8416c.tar.gz |
Fix the conversion macro for .note sections, broken in the case
the ELF file's byte order is not the native byte order. The
bug is that the variables holding the name and description size
are used (natively) after having been byte-swapped. The fix is
to calculate sz from them just prior to byte-swapping.
Approved by: jkoshy@
Obtained from: Juniper Networks, Inc.
Diffstat (limited to 'contrib/elftoolchain')
-rw-r--r-- | contrib/elftoolchain/libelf/libelf_convert.m4 | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/contrib/elftoolchain/libelf/libelf_convert.m4 b/contrib/elftoolchain/libelf/libelf_convert.m4 index 0e0e4fd..fda9392 100644 --- a/contrib/elftoolchain/libelf/libelf_convert.m4 +++ b/contrib/elftoolchain/libelf/libelf_convert.m4 @@ -947,6 +947,11 @@ _libelf_cvt_NOTE_tom(char *dst, size_t dsz, char *src, size_t count, READ_WORD(src, descsz); READ_WORD(src, type); + sz = namesz; + ROUNDUP2(sz, 4); + sz += descsz; + ROUNDUP2(sz, 4); + /* Translate. */ SWAP_WORD(namesz); SWAP_WORD(descsz); @@ -962,11 +967,6 @@ _libelf_cvt_NOTE_tom(char *dst, size_t dsz, char *src, size_t count, dst += sizeof(Elf_Note); count -= hdrsz; - ROUNDUP2(namesz, 4); - ROUNDUP2(descsz, 4); - - sz = namesz + descsz; - if (count < sz || dsz < sz) /* Buffers are too small. */ return (0); |