[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Bug-ocrad] OCRAD with Visual Studio 2010 success
From: |
Tilman Hausherr |
Subject: |
Re: [Bug-ocrad] OCRAD with Visual Studio 2010 success |
Date: |
Wed, 11 Aug 2010 18:32:12 +0200 |
On Wed, 11 Aug 2010 17:51:01 +0200, Antonio Diaz Diaz wrote:
>Tilman Hausherr wrote:
>> I can't, because both STDIN_FILENO and __MSVCRT__ don't exist, at least
>> not here in VS2010.
>
>OK. Maybe the following code works:
>
>#if defined(__MSVCRT__) || defined(_MSC_VER) || defined(__OS2__)
> setmode( fileno( stdin ), O_BINARY );
> setmode( fileno( stdout ), O_BINARY );
>#endif
Yes that works. Although I see no reason to set stdout to binary too,
except for philosophical reasons.
>>>>if( ( control.outfile = std::fopen( outfile_name, "wx" ) ) == 0 )
>>>
>>>I have to think about this because removing the 'x' breaks --force.
>>>(Files are always overwritten). Isn't there an equivalent to O_EXCL for
>>>streams?
>>
>> No, not in Visual C++ 2010, sadly.
>
>Using _access introduces an unavoidable race condition between the call
>to _access and the call to fopen. See
>https://www.securecoding.cert.org/confluence/display/seccode/FIO10-C.+Take+care+when+using+the+rename%28%29+function
>
>And given that the 'x' mode has been added to the C1X standard, probably
>the best option is you patch it until Visual C++ 201X implements it. See
>http://webcache.googleusercontent.com/search?q=cache:d8BBqkWymaYJ:https://www.securecoding.cert.org/confluence/download/attachments/26017980/WG14March2009%2Bv3.pdf?version%3D1%26modificationDate%3D1239645959000+%2Bfopen+%2BO_EXCL+%2BC1X&hl=en&gl=es
>page 9.
An alternative might be this (at the bottom):
https://www.securecoding.cert.org/confluence/display/seccode/FIO03-C.+Do+not+make+assumptions+about+fopen()+and+file+creation
Tilman
Re: [Bug-ocrad] OCRAD with Visual Studio 2010 success, Tilman Hausherr, 2010/08/10