X-Git-Url: http://git.efficios.com/?a=blobdiff_plain;f=opcodes%2Fdis-buf.c;h=19e3a6a0f7c69afb98d3fc1e98d3d614f94fadfc;hb=3c3d03769e4d6fea4c8ee97bf36a2ca7d572461c;hp=c2589ba03f1b935f756620d2dd28f9d5c0e67a33;hpb=01f0fe5e0450edf168c1f612feb93cf588e4e7ea;p=deliverable%2Fbinutils-gdb.git diff --git a/opcodes/dis-buf.c b/opcodes/dis-buf.c index c2589ba03f..19e3a6a0f7 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-2020 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);