From: Ian Jackson Subject: Re: [PATCH 14/16] libelf: use only unsigned integers Date: Tue, 4 Jun 2013 11:50:22 +0100 Message-ID: <20909.50798.511437.103236@mariner.uk.xensource.com> References: <1370274111-18377-1-git-send-email-ian.jackson@eu.citrix.com> <1370274111-18377-15-git-send-email-ian.jackson@eu.citrix.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <1370274111-18377-15-git-send-email-ian.jackson@eu.citrix.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: xen-devel@lists.xensource.com List-Id: xen-devel@lists.xenproject.org Ian Jackson writes ("[PATCH 14/16] libelf: use only unsigned integers"): > index f96ac7a..b47a9ca 100644 > --- a/xen/common/libelf/libelf-tools.c > +++ b/xen/common/libelf/libelf-tools.c > @@ -119,19 +119,19 @@ uint64_t elf_access_unsigned(struct elf_binary * elf, elf_ptrval base, > > uint64_t elf_round_up(struct elf_binary *elf, uint64_t addr) > { > - int elf_round = (elf_64bit(elf) ? 8 : 4) - 1; > + unsigned elf_round = (elf_64bit(elf) ? 8 : 4) - 1; > > return (addr + elf_round) & ~elf_round; > } It has been pointed out to me that this is wrong and truncates the value to 32-bit. The correct fix is to change elf_round to uint64_t. This shows a hole in the argument for the safety of this patch. Ian.