X-Git-Url: http://drtracing.org/?a=blobdiff_plain;f=opcodes%2Fdis-buf.c;h=e4911b9ecda77f51576705375e7fcacb93c7ab2a;hb=7243d0118af6f72e3e72db1eb66941fec4530963;hp=c2589ba03f1b935f756620d2dd28f9d5c0e67a33;hpb=01f0fe5e0450edf168c1f612feb93cf588e4e7ea;p=deliverable%2Fbinutils-gdb.git diff --git a/opcodes/dis-buf.c b/opcodes/dis-buf.c index c2589ba03f..e4911b9ecd 100644 --- a/opcodes/dis-buf.c +++ b/opcodes/dis-buf.c @@ -1,16 +1,17 @@ /* Disassemble from a buffer, for GNU. - Copyright 1993, 1994, 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2005 - Free Software Foundation, Inc. + Copyright (C) 1993-2018 Free Software Foundation, Inc. - This program is free software; you can redistribute it and/or modify + This file is part of the GNU opcodes library. + + This library is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. + the Free Software Foundation; either version 3, or (at your option) + any later version. - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. + It is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public + License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software @@ -31,12 +32,15 @@ buffer_read_memory (bfd_vma memaddr, struct disassemble_info *info) { unsigned int opb = info->octets_per_byte; - unsigned int end_addr_offset = length / opb; - unsigned int max_addr_offset = info->buffer_length / opb; - unsigned int octets = (memaddr - info->buffer_vma) * opb; + size_t end_addr_offset = length / opb; + size_t max_addr_offset = info->buffer_length / opb; + size_t octets = (memaddr - info->buffer_vma) * opb; if (memaddr < info->buffer_vma - || memaddr - info->buffer_vma + end_addr_offset > max_addr_offset) + || memaddr - info->buffer_vma > max_addr_offset + || memaddr - info->buffer_vma + end_addr_offset > max_addr_offset + || (info->stop_vma && (memaddr >= info->stop_vma + || memaddr + end_addr_offset > info->stop_vma))) /* Out of bounds. Use EIO because GDB uses it. */ return EIO; memcpy (myaddr, info->buffer + octets, length);