From owner-svn-src-head@FreeBSD.ORG Wed Oct 22 01:04:17 2014 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 00956897; Wed, 22 Oct 2014 01:04:16 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id E05779DF; Wed, 22 Oct 2014 01:04:16 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id s9M14G6f008814; Wed, 22 Oct 2014 01:04:16 GMT (envelope-from marcel@FreeBSD.org) Received: (from marcel@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id s9M14Gq8008813; Wed, 22 Oct 2014 01:04:16 GMT (envelope-from marcel@FreeBSD.org) Message-Id: <201410220104.s9M14Gq8008813@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: marcel set sender to marcel@FreeBSD.org using -f From: Marcel Moolenaar Date: Wed, 22 Oct 2014 01:04:16 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r273443 - head/contrib/elftoolchain/libelf X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 22 Oct 2014 01:04:17 -0000 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);