Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Nick Clifton <nickc@redhat.com>
To: mark@codesourcery.com
Cc: binutils@sources.redhat.com, gdb-patches@sources.redhat.com
Subject: Re: PATCH: Avoid accidentally opening files for write
Date: Tue, 07 Jun 2005 09:18:00 -0000	[thread overview]
Message-ID: <42A566C9.4040500@redhat.com> (raw)
In-Reply-To: <200506070717.j577HNq4006430@sethra.codesourcery.com>

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  <mark@codesourcery.com>
> 
> 	* 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 <<fdopen>> is used to open the file; otherwise, <<fopen>>
> ! 	is used.  @var{mode} is passed directly to <<fopen>> or
> ! 	<<fdopen>>. 
...
> !   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


  reply	other threads:[~2005-06-07  9:18 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-06-07  7:17 Mark Mitchell
2005-06-07  9:18 ` Nick Clifton [this message]
2005-06-07 15:53   ` Mark Mitchell
2005-06-07 19:23     ` Nick Clifton
2005-06-07 23:02       ` Mark Mitchell
2005-06-13  3:21 ` Daniel Jacobowitz
2005-06-13 18:44   ` Mark Mitchell

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=42A566C9.4040500@redhat.com \
    --to=nickc@redhat.com \
    --cc=binutils@sources.redhat.com \
    --cc=gdb-patches@sources.redhat.com \
    --cc=mark@codesourcery.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox