From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 2084 invoked by alias); 7 Jun 2005 09:18:05 -0000 Mailing-List: contact gdb-patches-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sources.redhat.com Received: (qmail 2063 invoked by uid 22791); 7 Jun 2005 09:18:00 -0000 Received: from mx1.redhat.com (HELO mx1.redhat.com) (66.187.233.31) by sourceware.org (qpsmtpd/0.30-dev) with ESMTP; Tue, 07 Jun 2005 09:18:00 +0000 Received: from int-mx1.corp.redhat.com (int-mx1.corp.redhat.com [172.16.52.254]) by mx1.redhat.com (8.12.11/8.12.11) with ESMTP id j579HwWo006308; Tue, 7 Jun 2005 05:17:58 -0400 Received: from pobox.surrey.redhat.com (pobox.surrey.redhat.com [172.16.10.17]) by int-mx1.corp.redhat.com (8.11.6/8.11.6) with ESMTP id j579HvO14682; Tue, 7 Jun 2005 05:17:58 -0400 Received: from [172.31.0.98] (vpnuser7.surrey.redhat.com [172.16.9.7]) by pobox.surrey.redhat.com (8.12.8/8.12.8) with ESMTP id j579HuLZ002910; Tue, 7 Jun 2005 10:17:57 +0100 Message-ID: <42A566C9.4040500@redhat.com> Date: Tue, 07 Jun 2005 09:18:00 -0000 From: Nick Clifton User-Agent: Mozilla Thunderbird 1.0 (X11/20041206) MIME-Version: 1.0 To: mark@codesourcery.com CC: binutils@sources.redhat.com, gdb-patches@sources.redhat.com Subject: Re: PATCH: Avoid accidentally opening files for write References: <200506070717.j577HNq4006430@sethra.codesourcery.com> In-Reply-To: <200506070717.j577HNq4006430@sethra.codesourcery.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-SW-Source: 2005-06/txt/msg00053.txt.bz2 Hi Mark, > Tested on x86_64-unknown-linux-gnu. OK to apply? Have you tested this patch in both POSIX and non-POSIX build environments ? Given your comments with the original posting I would assume so, but it would be nice to have that confirmed. Also with a patch to a generic part of BFD it would be good if you could also test with a --enable-targets=all build, just to make sure. > 2005-06-06 Mark Mitchell > > * opncls.c (bfd_fopen): New API. > (bfd_openr): Use it. > (bfd_fdopenr): Likewise. > * bfd-in2.h: Regenerated. The bfd part of your patch is approved. I do have one other concern however: > SYNOPSIS > ! bfd *bfd_fopen (const char *filename, const char *target, > ! const char *mode, int fd); > > DESCRIPTION > ! Open the file @var{filename} with the target @var{target}. > ! Return a pointer to the created BFD. If @var{fd} is not -1, > ! then <> is used to open the file; otherwise, <> > ! is used. @var{mode} is passed directly to <> or > ! <>. ... > ! if (strchr (mode, '+')) > ! nbfd->direction = both_direction; > ! else if (strchr (mode, 'r')) > ! nbfd->direction = read_direction; > ! else > ! nbfd->direction = write_direction; This assumes that the contents of 'mode' are well defined. Is this the case for non-POSIX environments ? For example can we be sure that the character 'R' is never used to indicate read-only status, or that an OS might allow a file created with just "a" to have the newly-written-to parts read back, effectively making "a" a read-and-write mode ? What I am getting at is, should bfd_fopen() take an explicit extra parameter which tells BFD whether this file is intended for reading, writing or both ? Cheers Nick