Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 23 Jan 2015 02:39:00 +0000 (UTC)
From:      Ed Maste <emaste@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org
Subject:   svn commit: r277557 - stable/10/usr.sbin/crunch/crunchide
Message-ID:  <201501230239.t0N2d0jH072013@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: emaste
Date: Fri Jan 23 02:39:00 2015
New Revision: 277557
URL: https://svnweb.freebsd.org/changeset/base/277557

Log:
  crunchide: Correct 64-bit section header offset
  
  For 64-bit binaries the Elf_Ehdr e_shoff is at offset 40, not 44.
  Instead of using an incorrect hardcoded offset, let the compiler
  figure it out for us with offsetof().
  
  MFC of r277259

Modified:
  stable/10/usr.sbin/crunch/crunchide/exec_elf32.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/usr.sbin/crunch/crunchide/exec_elf32.c
==============================================================================
--- stable/10/usr.sbin/crunch/crunchide/exec_elf32.c	Fri Jan 23 01:39:04 2015	(r277556)
+++ stable/10/usr.sbin/crunch/crunchide/exec_elf32.c	Fri Jan 23 02:39:00 2015	(r277557)
@@ -46,6 +46,7 @@ __FBSDID("$FreeBSD$");
 
 #include <errno.h>
 #include <limits.h>
+#include <stddef.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
@@ -464,7 +465,7 @@ ELFNAMEEND(hide)(int fd, const char *fn)
 			if (layoutp[i].shdr == &shdrshdr &&
 			    ehdr.e_shoff != shdrshdr.sh_offset) {
 				ehdr.e_shoff = shdrshdr.sh_offset;
-				off = (ELFSIZE == 32) ? 32 : 44;
+				off = offsetof(Elf_Ehdr, e_shoff);
 				size = sizeof(Elf_Off);
 				if ((size_t)xwriteatoff(fd, &ehdr.e_shoff, off, size,
 				    fn) != size)



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