Date: Tue, 2 Dec 2014 22:35:44 +0000 (UTC) From: Ed Maste <emaste@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r275430 - head/contrib/elftoolchain/libelf Message-ID: <201412022235.sB2MZihq086311@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: emaste Date: Tue Dec 2 22:35:43 2014 New Revision: 275430 URL: https://svnweb.freebsd.org/changeset/base/275430 Log: libelf: Fix cross-endian ELF note file / memory conversion The namesz and descsz variables need to be used in native endianness. The sizes are in native order after swapping in the file to memory case, and before swapping in the memory to file case. This issue was identified for r273443, but the change was applied to the wrong case. Revert r273443 to fix the to-memory case, and apply the equivalent change to the to-file case. Sponsored by: DARPA, AFRL Reviewed by: adrian, brooks, marcel Differential Revision: https://reviews.freebsd.org/D1257 Modified: head/contrib/elftoolchain/libelf/libelf_convert.m4 Modified: head/contrib/elftoolchain/libelf/libelf_convert.m4 ============================================================================== --- head/contrib/elftoolchain/libelf/libelf_convert.m4 Tue Dec 2 22:04:27 2014 (r275429) +++ head/contrib/elftoolchain/libelf/libelf_convert.m4 Tue Dec 2 22:35:43 2014 (r275430) @@ -947,11 +947,6 @@ _libelf_cvt_NOTE_tom(char *dst, size_t d 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); @@ -967,6 +962,11 @@ _libelf_cvt_NOTE_tom(char *dst, size_t d 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); @@ -1005,6 +1005,11 @@ _libelf_cvt_NOTE_tof(char *dst, size_t d descsz = en->n_descsz; type = en->n_type; + sz = namesz; + ROUNDUP2(sz, 4); + sz += descsz; + ROUNDUP2(sz, 4); + SWAP_WORD(namesz); SWAP_WORD(descsz); SWAP_WORD(type); @@ -1015,11 +1020,6 @@ _libelf_cvt_NOTE_tof(char *dst, size_t d src += sizeof(Elf_Note); - ROUNDUP2(namesz, 4); - ROUNDUP2(descsz, 4); - - sz = namesz + descsz; - if (count < sz) sz = count;
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201412022235.sB2MZihq086311>