Re: Migrating VC6.0 -> Visual Studion 2008 - depricated functions

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



Interesting. I had not actually noticed that. But now there's a serious problem: suppose
I WANT to open the file with _SH_DENYNO. For example, if I want to open it in sharable
mode and I want to specify the encoding used. I note that _fsopen/_wfsopen/_tfsopen do
not appear to allow the ccs=encoding option. So instead of giving me complete control, I
only get a subset of the specifications in one (fopen_s) and a different, exlusive, subset
of specifications in another. But there appears to be no way to open a file in the C
library if I need to specify both sharing and encoding.

Unless, of course, _fsopen and _wfsopen allow me to specify the encoding, but neglected to
document it. I'm a bit busy today, and don't want to look it up, but I'm adding it as a
project to look into for my "errors and omissions" document.

[Side note: the MASM documentation in the MSDN has to be among the worst documentation I
have ever seen; it doesn't even give basic identifier syntax, uses some constructs whose
syntax is never even described ("initializer") and makes reference to pieces of syntax ("a
constant starting with %") that are never, ever explained anywhere else. I'm slowly
adding these to my list as I develop a course in assembly code programming]

Note that I hardly ever use the raw C library; I tend to use CStdioFile::Open to get file
objects for simple text I/O, which does allow me to set all the state I want.
joe
On Wed, 11 Nov 2009 02:41:55 -0600, Scot Brennecke <ScotB@xxxxxxxxxxxxxxxxxx> wrote:

Joseph M. Newcomer wrote:
I find the fopen_s a truly weird mechanism, since there was nothing that could cause a
"buffer overflow" in fopen.

Well, the "_s" is for "safe", not necessarily "safe from buffer
overflows". In the case of fopen_s, the sharing mode defaults to
_SH_SECURE instead of _SH_DENYNO. Also, the use of a FILE** parameter
instead of a FILE * return code might make it slightly harder for people
to do something stupid and dangerous with the return value.
Joseph M. Newcomer [MVP]
email: newcomer@xxxxxxxxxxxx
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
.



Relevant Pages

  • Re: Proposal: INHERIT, NOINHERIT
    ... Just a word of how J3's new features procedures work ... ... justifying the feature, and saying *exactly* what it is. ... Only after the above, propose syntax. ... the specifications it's hard to judge the syntax. ...
    (comp.lang.fortran)
  • Re: Proposal: INHERIT, NOINHERIT
    ... Just a word of how J3's new features procedures work ... ... Only after the above, propose syntax. ... the specifications it's hard to judge the syntax. ... write edits against the current draft of the standard. ...
    (comp.lang.fortran)
  • Re: regex help needed
    ... and looking for: ab2 in line 2 ... should say (syntax) to return the results I'm looking for: if ab1/ab2 ... But you may need to provide a few more specifications and example data ...
    (perl.beginners)