Thread: FILE* question

  1. #16
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,653
    Quote Originally Posted by matsp View Post
    Safe libraries is fine, but what about the code that isn't in the libraries. How do you make THAT code safe?[/code]
    Lots of vulnerabilities come from improper memory handling, like buffer overruns.
    And usually this is due to C-style functions. Using C++ objects usually takes care of that little problem for you.
    Otherwise you need to properly learn how to handle memory yourself.
    I believe that is THE biggest problem in the language.

    Surely you don't mean to say that all applications can only be produced by calling functions in safe libraries?
    No, of course not. But using safe libraries lessens the risk for programming errors and mistakes and vulnerabilities, so it's a good thing to use them.
    Last edited by Elysia; 12-01-2007 at 03:36 PM.

  2. #17
    Registered User
    Join Date
    Aug 2007
    Posts
    81
    There are safe and secure libraries for both C and C++. There are novice programmers in both languages that neglect these libraries. Basing the security of a language on its library support is not the way to go for this reason. Unless there was some way to get rid of all the old insecure libraries so new programmers don't keep using them...

    C and C++ are terrible bug prone languages. Although I do prefer to program in C++ rather than in C because I like the STL and private data types.

  3. #18
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,653
    Quote Originally Posted by keira View Post
    There are safe and secure libraries for both C and C++. There are novice programmers in both languages that neglect these libraries. Basing the security of a language on its library support is not the way to go for this reason. Unless there was some way to get rid of all the old insecure libraries so new programmers don't keep using them...
    Oh how we'd love that, but seeing as lots still use plain old C, I can't see that happening anytime soon, unfortunately.

  4. #19
    Deathray Engineer MacGyver's Avatar
    Join Date
    Mar 2007
    Posts
    3,210
    Quote Originally Posted by Elysia View Post
    And usually this is due to C-style functions. Using C++ objects usually takes care of that little problem for you.
    Otherwise you need to properly learn how to handle memory yourself.
    I believe that is THE biggest problem in the language.
    You don't manage memory in C++?

  5. #20
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,653
    With smart pointers, string classes, vectors... all that complexity of keeping your arrays intact and all that goes away. No need to worry about it. And that's pretty much the biggest issues with memory.
    I can't think of an example in a general program where I have to handle memory myself with a raw array, raw buffer or such (well substitute raw buffer for vector for that purpose).
    Now there's where the most of the work goes into, no? To make all that work like it should?

  6. #21
    Deathray Engineer MacGyver's Avatar
    Join Date
    Mar 2007
    Posts
    3,210
    You never use dynamic memory explicitly?

  7. #22
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,401
    I suggest that we (especially you, Elysia) stop starting "C versus C++" and other language comparison discussions in the middle of threads that have nothing to do with language comparison.
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  8. #23
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,653
    I do, of course. I know how to handle it properly.
    But most of the time, I know I can get away with not doing it.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Alice....
    By Lurker in forum A Brief History of Cprogramming.com
    Replies: 16
    Last Post: 06-20-2005, 02:51 PM
  2. Debugging question
    By o_0 in forum C Programming
    Replies: 9
    Last Post: 10-10-2004, 05:51 PM
  3. Question about pointers #2
    By maxhavoc in forum C++ Programming
    Replies: 28
    Last Post: 06-21-2004, 12:52 PM
  4. Question...
    By TechWins in forum A Brief History of Cprogramming.com
    Replies: 16
    Last Post: 07-28-2003, 09:47 PM
  5. Question, question!
    By oskilian in forum A Brief History of Cprogramming.com
    Replies: 5
    Last Post: 12-24-2001, 01:47 AM