Thread: Switch Problem

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    Quote Originally Posted by cyberfish View Post
    I'm gonna say it's just another Microsoft attempt at vendor lock-in.
    But it isn't. It performs additional security checks that scanf doesn't.

    So I suggest changing it back to scanf for standard compliance (unless there is something I missed).
    I suggest not changing it. For standards compliance, all they have to do is add #define scanf_s scanf.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  2. #2
    Hurry Slowly vart's Avatar
    Join Date
    Oct 2006
    Location
    Rishon LeZion, Israel
    Posts
    6,788
    Quote Originally Posted by Elysia View Post
    But it isn't. It performs additional security checks that scanf doesn't.



    I suggest not changing it. For standards compliance, all they have to do is add #define scanf_s scanf.
    And why standards cometee should follow Microsoft and not the opposite?
    All problems in computer science can be solved by another level of indirection,
    except for the problem of too many layers of indirection.
    – David J. Wheeler

  3. #3
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    Quote Originally Posted by cyberfish View Post
    Such as? (except the field width, which scanf can do, too)


    That is not true if you are actually using scanf_s's "security feature" of adding a field width for every %s. If you are just using it as scanf, might as well just use scanf.
    I can't details exactly, because I don't know. But the link mentions "typical" enhancements the secure versions have.
    And even if it were just a plain old scanf call, I'd still use scanf_s to get rid of warnings.

    Quote Originally Posted by vart View Post
    And why standards cometee should follow Microsoft and not the opposite?
    The standards committee doesn't seem to care about security stuff. If it did, we wouldn't be in this mess in the first place!
    As it stands now, Microsoft is filling the gap that the standards committee hasn't.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  4. #4
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    Quote Originally Posted by Elysia View Post
    As it stands now, Microsoft is filling the gap that the standards committee hasn't.
    Bwhahaha. Just like they "filled the gap" that JAVA had?


    Quzah.
    Hope is the first step on the road to disappointment.

  5. #5
    Officially An Architect brewbuck's Avatar
    Join Date
    Mar 2007
    Location
    Portland, OR
    Posts
    7,396
    Quote Originally Posted by Elysia View Post
    I can't details exactly, because I don't know. But the link mentions "typical" enhancements the secure versions have.
    And even if it were just a plain old scanf call, I'd still use scanf_s to get rid of warnings.
    Funny, I use /D_CRT_SECURE_NO_WARNINGS to get rid of them.

    The problem with scanf_s() and its ilk is that it leads people to believe that all they need to do is call this "secure" function and they will magically have security. It's still possible to pass an incorrect buffer size and get an overflow anyway.

    Input validation is always necessary. Having a set of functions which are deemed "more secure" than some other functions encourages people to be lax and not think about the issues.

    As far as the standards committees not considering security, why should they?
    Code:
    //try
    //{
    	if (a) do { f( b); } while(1);
    	else   do { f(!b); } while(1);
    //}

  6. #6
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    Quote Originally Posted by quzah View Post
    Bwhahaha. Just like they "filled the gap" that JAVA had?
    Quzah.
    True, they have made a lot of poor things. Yet, at least we can choose to use them or not.

    Quote Originally Posted by brewbuck View Post
    Funny, I use /D_CRT_SECURE_NO_WARNINGS to get rid of them.

    The problem with scanf_s() and its ilk is that it leads people to believe that all they need to do is call this "secure" function and they will magically have security. It's still possible to pass an incorrect buffer size and get an overflow anyway.

    Input validation is always necessary. Having a set of functions which are deemed "more secure" than some other functions encourages people to be lax and not think about the issues.
    Anything that is more safe is better in my book.
    Just because it's more secure, it doesn't mean it encourages people to be more lazy. I rather think of as gets vs fgets. And this applies not only to buffer size (which there are a number of, such as strcpy_s), but anything security-related, standard or not.

    As far as the standards committees not considering security, why should they?
    Because it's a HUGE problem in today's world?
    It just shows that the C standards committee doesn't really "care" about modern systems in my book.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Switch statement problem
    By jalex39 in forum C Programming
    Replies: 6
    Last Post: 03-08-2008, 04:05 PM
  2. problem on switch
    By toxicherry in forum C Programming
    Replies: 11
    Last Post: 12-31-2007, 05:17 AM
  3. Switch Problem
    By Tynnhammar in forum C++ Programming
    Replies: 2
    Last Post: 09-16-2004, 11:57 AM
  4. Replies: 1
    Last Post: 08-31-2004, 04:07 AM
  5. Uh-oh! I am having a major switch problem!
    By goodn in forum C Programming
    Replies: 4
    Last Post: 11-01-2001, 04:49 PM