Slashdot Mirror


Secure, Efficient and Easy C programming

cras writes "Feeling a bit of masochist today.. First in the morning I wrote Secure, Efficient and Easy C Programming Mini-HOWTO. And since I already spent a few hours with it, I figured I might just as well see what Slashdot people would think about it."

28 of 347 comments (clear)

  1. Secure, Efficient and Easy by Anonymous Coward · · Score: 5, Funny

    Pick any two.

  2. future plans? by napoleonin · · Score: 5, Funny

    "First in the morning I wrote Secure, Efficient and Easy C Programming Mini-HOWTO..."

    Damn. What are your plans for the rest of the day?

    1. Re:future plans? by roseblood · · Score: 0, Funny

      1) write Secure, Efficient and Easy C Programming Mini-HOWTO [done]
      2) ???
      3) Profit!

      --
      There are lies, damned lies, and statistics.
    2. Re:future plans? by Reality+Master+101 · · Score: 5, Funny

      Maybe make it a HOWTO rather than a Mini-HOWTO? Hell, I could write a mini-HOWTO right here...

      SECURE

      1) Don't use strcpy.

      2) Don't assume data coming in from the world is within valid limits

      EFFICIENT

      1) Avoid moving/copying large amounts of data whenever possible. Work in place.

      EASY

      1) Don't redefine the language using macros (e.g., define BEGIN {, #define END })

      2) Comment your source

      3) Use The One True Brace Style. All others are heretical crap.

      Damn, now what do I do with the rest of my day?

      --
      Sometimes it's best to just let stupid people be stupid.
    3. Re:future plans? by Anonymous Coward · · Score: 1, Funny

      Actually yours is better.

    4. Re:future plans? by vsprintf · · Score: 3, Funny

      Use The One True Brace Style. All others are heretical crap.

      As long at that's my brace style (K&R), you are correct.

    5. Re:future plans? by 0x0d0a · · Score: 4, Funny

      "First in the morning I wrote Secure, Efficient and Easy C Programming Mini-HOWTO..."

      Damn. What are your plans for the rest of the day?


      "If you've done six impossible things this morning, why not round it off with breakfast at Milliways, the Restauraunt at the End of the Universe?"

      -- Douglas Adams

    6. Re:future plans? by iangoldby · · Score: 2, Funny

      NO!!

  3. Hmm.. Question by Loki_1929 · · Score: 4, Funny

    "First in the morning I wrote"

    So did you wake up early this morning, or are you still up from the night before, like me?

    --
    -- "Government is the great fiction through which everybody endeavors to live at the expense of everybody else."
    1. Re:Hmm.. Question by cras · · Score: 2, Funny

      Read the article ;) 27h uptime or so now. I woke up around 6pm though.

  4. Mirror of HOW-TO in case it gets slashdotted by CableModemSniper · · Score: 5, Funny

    1) Use python with C bindings

    --
    Why not fork?
    1. Re:Mirror of HOW-TO in case it gets slashdotted by Anonymous Coward · · Score: 1, Funny

      No, no it's:

      #include <unistd.h>
      int main(int argc, char **argv)
      {
      return system("perl myscript.pl");
      }

  5. Voluntary slashdotting by tuxlove · · Score: 3, Funny

    It's kind of funny how this guy voluntarily slashdotted himself by submitting an article with a link to his own site, crashing it instantly. :)

    1. Re:Voluntary slashdotting by Anonymous Coward · · Score: 3, Funny

      I think Slashdotting only really happens to sites with dynamic content or to sites with a topic more people care about. Oh yeah, and also sites that run on a calculator powered by a potato.

  6. It's a Sunday morning; So don't criticize. by dagg · · Score: 4, Funny
    I'm not a writer and I'm not too good at english, so sorry about all the spelling and grammar errors :) All of this stuff was written at sunday morning, tired after being awake the whole night and not being able to do anything useful...

    I'm going to start putting that at the end of everything I write so that people can't criticize anything I do. As a matter of fact... I think I'll only write on Sunday mornings after not sleeping the night before. It seems like it's always Sunday morning anyways.

    --
    Your sex on a Sunday Morning
    --
    Sex - Find It
  7. masochist by mike77 · · Score: 2, Funny
    Feeling a bit of masochist today...

    You must be to ask slashdot's opinion of your toils!

    --

    --Keeping the flame wars alive, one post at a time

  8. You Forgot: by asv108 · · Score: 5, Funny
    You forgot to add the obligatory "in XX days" or "XX hours" to your title. So a better title for this story would be:

    "Secure, Efficient and Easy C programming in 24hrs"

  9. Re:a little short?? by TheAncientHacker · · Score: 2, Funny

    Impossible. C, itself, is a bad habit.

  10. visual basic by Anonymous Coward · · Score: 3, Funny

    why not just use visual basic?

    say what you want about it, you don't have to use stupid hacks to avoid buffer overflows.

  11. Re:+1 Insightful by Twirlip+of+the+Mists · · Score: 5, Funny

    Perl is for idiots who think regexps can solve all problems.

    s/idiots/wise souls/
    s/think/know/

    Problem solved.

    --

    I write in my journal
  12. Re:+1 Insightful by Anonymous Coward · · Score: 0, Funny

    do us all a favour

    favour? favour? what are you, the fucking queen or something? god save this, you crusty old bitch.

  13. Re:stack allocation?? by PissingInTheWind · · Score: 3, Funny

    Boehm GC can't do much with C.

    I find it somewhat ironic that you make claims like that, and that you write a memory management HOWTO at the same time.

    But eh, keep hacking at that square wheel.

    --

    A message from the system administrator: 'I've upped my priority. Now up yours.'
  14. Re:a little short?? by vsprintf · · Score: 3, Funny

    Damn true, using C for other thing than low-level stuff really is a bad habit.

    Oh, God, another Visual Basic user who writes code with a mouse. Spare me.

  15. Re:stack allocation?? by cras · · Score: 2, Funny

    Well, I'm getting a bit tired of arguing. Even it the speed didn't matter at all, there's still the point that you can't create easily usable GC with C portably. And I don't feel restricted at all with the data stack. Yes, it's a bit more restrictive when comparing to fully automatic GC, but still much less PITA than having to free() the memory which everyone else are doing.

    I don't care about speed that much. Portability is one however which I really do care about and I'd hate to depend on requiring an implementation of GC for some specific platform I intend to use.

    Telling GC about all your structures sounds much more difficult and error-prone to me than my simple data stack.

  16. Re:a little short?? by dvdeug · · Score: 5, Funny

    Damn true, using C for other thing than low-level stuff really is a bad habit.

    Oh, God, another Visual Basic user who writes code with a mouse. Spare me.

    Yes, because it's better to spend weeks and months carefully constructing a GUI by hand then to put it together in a couple days with a mouse. Especially if it's going to be used by three or four people; by God, it's more than worth it to the company for me to spend two or three months on the project (@ $60,000 a year) so those people can get their results back in a couple seconds rather than a couple minutes.

    It's also better to spend weeks and months writing an efficent text processing program in C and worrying about buffer overflows and memory leaks, rather then writting it in a couple days in Perl or Snobol. Who cares that the results will inevitably be piped to less and studied for a few minutes; the fact that we shaved off 40% of 2 seconds (and added an obscure error case) is more than worth it!

    Actually: Oh, God, another C programmer that will make me suffer through anonymous core dumps because his programming language is so much more macho, and so much more efficent (really wish he understand how to use Big-O notation and switch algorithms, but he spent so much time programming this one and dubugging it that he can't afford to switch. Too bad he doesn't use a language with efficent control structures predebugged and optimized.)

  17. Re:a little short?? by PissingInTheWind · · Score: 3, Funny

    Did I sense irony? :-)

    But my infinite loops runs *so* fast!

    And what would I do without my precious core dumps?

    I can't trust the computer to manage his memory!

    Who cares about algorithms if the language is fast?

    I could not live without '\0' delimited strings!

    Strong typing sucks. Dynamic typing sucks. I like my types to have no purpose other than sizing the fields in memory.

    Error control and safety are for wimps.

    Macros should be dumb text substitution tools.

    --

    A message from the system administrator: 'I've upped my priority. Now up yours.'
  18. Re:Definitely useful by The+Madpostal+Worker · · Score: 3, Funny
    glue != prototype. (in fact, it's E210: invalid type comparison, cannot compare apples and oranges.


    I'm tired of this constant discrimination against the citrus fuits. One of these days the people will get up and say "I'm tired of people thinking that oranges aren't good enough for comparison." They'll say "I can compare apples and oranges". They'll run to the windows and say "This orange is much yellower than this apple". People will be running through the streets screaming "This apple is much more smooth than this orange."

    And then my group(The People for the Ethical treatment of Cirtrus (PETC)) will be happy.
    --

    /*
    *Not a Sermon, Just a Thought
    */
  19. Re:Unportable? by Anonymous Coward · · Score: 2, Funny
    No offense to purists, but screw the standard. I'll sacrifice some portability of software and such for security.
    A famous founding father of C reputedly said:

    [Those] that can give up portability to obtain a little temporary security deserve neither portable code nor secure code.