This is the mail archive of the binutils@sources.redhat.com mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: PATCH: Avoid accidentally opening files for write


Hi Mark,

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.

I didn't know about that, but will try it before check-in.

Thanks.


Just a build, or should I try to run some kind of testsuite as well?

Just a build, since there will no binutils executable which will exercise the new code anyway. (You could run a GDB testsuite with a patched GDB linked against the BFD library built for an all targets toolchain but I think that is needlessly paranoid).


> (Is there a way to run the binutils testuite on all targets all at once?)

Not really. You can run the binutils testsuites with an all-targets toolchain but it will just check the toolchain's default target, not all of the targets it can possibly support.

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 ?


Hmm. In practice, we always use one of the FOPEN_* macros as an argument, and these do follow the rules implied by what I wrote. But, I could tighten the test to check for just what ISO C requires, which is that the characters must occur at the start of the string, so using strchr is probably incorrect. OK to make that change before check-in, or would you like me to resubmit?

No please just make the change before check-in.


I'm not aware of OSes that do as you say, but, in any case, I don't think we need to worry about OSes that accept other variations. Clients of BFD should be using the standard syntax. It's OK if they use OS extensions, but I think it's reasonable to say that if they mean "read" they use "r" and not "R".

Fair enough.


Cheers
  Nick



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]