Use "secure" function warnings

Discussions About CyanWorlds.com Engine Client & Plugin
Post Reply
MustardJeep
Member
Posts: 54
Joined: Sat Dec 27, 2008 8:15 pm

Use "secure" function warnings

Post by MustardJeep »

me again,

sort of related to the int to bool thread I just posted but I figure I am probably in the minority on this issue. compiling under vs2010 there are several dozens if not several hundred warnings that function "X" is unsafe/depreciated please consider using function "Y" the more secure variant. Using these versions of the functions breaks compatibility with non-Microsoft compilers, but I decided to start converting them anyway. Nothing against other compilers but I'm not using them so I really feel no pain on breaking comparability with them.

Question is: Is anyone else converting to the "secure" functions? and would you like to swap implementations?

I know my implementations are a bit scuzzy but figured it was worth it to clear the warnings out of the output list, and more importantly it adds several hundred buffer overflow checks across the board.

edit
warning C4996: 'sprintf': This function or variable may be unsafe. Consider using sprintf_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.

As promised here's the warning, the specific functions vary but they all seem to use this basic warning text. I figure I'm in the minority for clearing the warnings on these functions since disabling them is by far the simplest solution. Still figured I'd post it up as a offer.
User avatar
Marten
Member
Posts: 180
Joined: Fri Dec 26, 2008 1:19 am

Re: Use "secure" function warnings

Post by Marten »

Couldn't you just do something like this?

#ifdef SAFE_FUNCTIONS
#define sprintf sprintf_s
#endif

... where SAFE_FUNCTIONS is a value defined by Microsoft compilers that support the "safe" functions?

It's my understanding that the _s functions are parameter-type and parameter-order compatible.
The music is reversible, but time is not.
MustardJeep
Member
Posts: 54
Joined: Sat Dec 27, 2008 8:15 pm

Re: Use "secure" function warnings

Post by MustardJeep »

you could do it that way I suppose.

For various personal reasons I'm going with the added buffer check parameter enabled, which makes that implementation some what problematic. ;) At the moment my sources are without a doubt the most crash-tastic ones anyone has ever coded on purpose. Once this versions done I intend to write in proper error handeling routines for all of them, but right now the default behavior without error handeling will crash the engine without processing the error.

I know it sounds odd but it's on track wih my long term goals for he engine.
Post Reply

Return to “CyanWorlds.com Engine - Client & Plugin”