From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 24082 invoked by alias); 15 Jul 2014 04:17:46 -0000 Mailing-List: contact binutils-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: binutils-owner@sourceware.org Received: (qmail 23978 invoked by uid 89); 15 Jul 2014 04:17:34 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=AWL,BAYES_00,FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,SPF_PASS autolearn=ham version=3.3.2 X-HELO: mail-pd0-f177.google.com Received: from mail-pd0-f177.google.com (HELO mail-pd0-f177.google.com) (209.85.192.177) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-SHA encrypted) ESMTPS; Tue, 15 Jul 2014 04:17:32 +0000 Received: by mail-pd0-f177.google.com with SMTP id p10so3002056pdj.22 for ; Mon, 14 Jul 2014 21:17:31 -0700 (PDT) X-Received: by 10.68.167.133 with SMTP id zo5mr20361155pbb.21.1405397851176; Mon, 14 Jul 2014 21:17:31 -0700 (PDT) Received: from bubble.grove.modra.org (CPE-58-160-155-134.oycza5.sa.bigpond.net.au. [58.160.155.134]) by mx.google.com with ESMTPSA id xk1sm53002382pac.21.2014.07.14.21.17.29 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 14 Jul 2014 21:17:30 -0700 (PDT) Received: by bubble.grove.modra.org (Postfix, from userid 1000) id 97F08EA3661; Tue, 15 Jul 2014 13:47:26 +0930 (CST) Date: Tue, 15 Jul 2014 04:17:00 -0000 From: Alan Modra To: binutils@sourceware.org Subject: Account for trailing bytes read from bfd_bread Message-ID: <20140715041726.GU8039@bubble.grove.modra.org> Mail-Followup-To: binutils@sourceware.org MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) X-IsSubscribed: yes X-SW-Source: 2014-07/txt/msg00144.txt.bz2 Noticed when debugging the >2G obstack corruption of gdb data. When we have a truncated read, we ought to return the amount read. Not that it matters very much on an error return.. * cache.c (cache_bread_1): Don't return -1 when fread returns a positive value. diff --git a/bfd/cache.c b/bfd/cache.c index 27fe70a..ffda004 100644 --- a/bfd/cache.c +++ b/bfd/cache.c @@ -310,7 +310,7 @@ cache_bread_1 (struct bfd *abfd, void *buf, file_ptr nbytes) if (nread == (file_ptr)-1) { bfd_set_error (bfd_error_system_call); - return -1; + return nread; } #else nread = fread (buf, 1, nbytes, f); @@ -320,7 +320,7 @@ cache_bread_1 (struct bfd *abfd, void *buf, file_ptr nbytes) if (nread < nbytes && ferror (f)) { bfd_set_error (bfd_error_system_call); - return -1; + return nread; } #endif if (nread < nbytes) -- Alan Modra Australia Development Lab, IBM