Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 22 Oct 2014 01:04:16 +0000 (UTC)
From:      Marcel Moolenaar <marcel@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r273443 - head/contrib/elftoolchain/libelf
Message-ID:  <201410220104.s9M14Gq8008813@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
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);
 



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201410220104.s9M14Gq8008813>