svn commit: r273443 - head/contrib/elftoolchain/libelf

Marcel Moolenaar marcel at FreeBSD.org
Wed Oct 22 01:04:17 UTC 2014


Author: marcel
Date: Wed Oct 22 01:04:16 2014
New Revision: 273443
URL: https://svnweb.freebsd.org/changeset/base/273443

Log:
  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.

Modified:
  head/contrib/elftoolchain/libelf/libelf_convert.m4

Modified: head/contrib/elftoolchain/libelf/libelf_convert.m4
==============================================================================
--- head/contrib/elftoolchain/libelf/libelf_convert.m4	Wed Oct 22 00:58:50 2014	(r273442)
+++ head/contrib/elftoolchain/libelf/libelf_convert.m4	Wed Oct 22 01:04:16 2014	(r273443)
@@ -947,6 +947,11 @@ _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);
@@ -962,11 +967,6 @@ _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);
 


More information about the svn-src-head mailing list