Slashdot Mirror


33-Year-Old Unix Bug Fixed In OpenBSD

Ste sends along the cheery little story of Otto Moerbeek, one of the OpenBSD developers, who recently found and fixed a 33-year-old buffer overflow bug in Yacc. "But if the stack is at maximum size, this will overflow if an entry on the stack is larger than the 16 bytes leeway my malloc allows. In the case of of C++ it is 24 bytes, so a SEGV occurred. Funny thing is that I traced this back to Sixth Edition UNIX, released in 1975."

162 comments

  1. Time to patch by Anonymous Coward · · Score: 5, Funny

    Wouldn't want to let anyone take over your system with yacc. Seriously.

    1. Re:Time to patch by slew · · Score: 5, Funny

      Wouldn't want to let anyone take over your system with yacc. Seriously.

      But ./ is already taken over with yak. Seriously.

    2. Re:Time to patch by Anonymous Coward · · Score: 4, Funny

      Who cares about OpenBSD yacc? BSD is dying and Netcraft confirms it. The world has moved to GNU/Linux and Bison.

    3. Re:Time to patch by dosius · · Score: 1

      Ugh. I still use byacc as my yacc of choice because Bison, like all GNUware, is bloated.

      -uso.

      --
      What you hear in the ear, preach from the rooftop Matthew 10.27b
    4. Re:Time to patch by msuarezalvarez · · Score: 3, Funny

      So you are including bison in your own apps and its `bloatedness' becomes a problem? Maybe you should read the manpage...

    5. Re:Time to patch by cryptoluddite · · Score: 1

      Wouldn't want to let anyone take over your system with yacc. Seriously.

      I think if you've installed yacc with setuid bit then you have other problems to worry about. Seriously.

    6. Re:Time to patch by Schraegstrichpunkt · · Score: 1

      What, so in the "Web 2.0" world, it would inconceivable that somebody would provide a web-accessible yacc service to the world?

    7. Re:Time to patch by setagllib · · Score: 3, Interesting

      Who cares? Like GCC versus TinyCC, being bloated means it can produce a more useful output. GNUware can be faulted for being heavy compared to traditional Unix tools, but the functionality and flexibility provided more than makes up for it.

      Except for autotools. What the HELL were they thinking.

      --
      Sam ty sig.
    8. Re:Time to patch by setagllib · · Score: 3, Funny

      Ah, but it would be written as a J2EE application. And the input wouldn't be .y, it'd be an XML document. And the output wouldn't be C, it'd be another XML, passing through a terabyte of XSLT. Then you pass this compiled parser XML, only a gigabyte in size, and your language file to a parser web service and it returns even more XML representing the parse tree.

      Ahh, progress.

      --
      Sam ty sig.
    9. Re:Time to patch by wylderide · · Score: 1

      Better than your system taken over Yahoo Seriously.

      --
      This is the best restaurant I ever eat in
    10. Re:Time to patch by TapeCutter · · Score: 4, Funny

      Great post, I'm still laughing as I type.

      Speaking of old bugs the guy who sits next to me at work hooked a 15yo mainfame bug a few months back. His stock comment whenever someone mentions it is: "Three more years and that one would have been old enough to vote!"

      --
      And did you exchange a walk on part in the war for a lead role in a cage? - Pink Floyd.
    11. Re:Time to patch by Anonymous Coward · · Score: 0

      If I understood the problem correctly, it's not yacc itsself that is insecure, but the program that it generates. If a tool has a builtin parser generated by yacc and you have the setuid bit on that, then it may be a risk.

    12. Re:Time to patch by Anonymous Coward · · Score: 0

      Care to point out what exactly bison does that is so useful? Its not any better than yacc, just far bigger and slower.

    13. Re:Time to patch by DeskLazer · · Score: 1

      /. you've just been yukked, yak.

    14. Re:Time to patch by Anonymous Coward · · Score: 0

      dotslash? taken over? no wonder I couldn't find it!

    15. Re:Time to patch by Haeleth · · Score: 1

      Care to point out what exactly bison does that is so useful? Its not any better than yacc

      Re-entrant parsers.

    16. Re:Time to patch by Anonymous Coward · · Score: 0

      Have you even checked whether or not this bug exists in Bison?

    17. Re:Time to patch by OttoM · · Score: 1

      I think you missed the point. The bug is in the code generated by yacc, which can end up anywhere.

    18. Re:Time to patch by Anonymous Coward · · Score: 0

      Who cares about Linux and Bison? The world moved to windows a long time ago!

  2. From back when by Yold · · Score: 4, Funny

    Unix beards were Unix stubble

  3. bad omen by spir0 · · Score: 4, Funny

    a 33 year old bug, plus a 25 year old bug (http://it.slashdot.org/article.pl?sid=08/05/11/1339228)....

    if we keep going backwards, will the world implode? or will daemons start spewing out of cracks in time and space?

    --
    The reason girls and Windows users don't understand UNIX is because all the documentation is in Man files.
    1. Re:bad omen by je+ne+sais+quoi · · Score: 4, Funny

      Nah! What this means is that they are fixing bugs faster than they're making new ones. If they weren't, they'd spend all their time chasing the newest ones. :)

      --
      Gentlemen! You can't fight in here, this is the war room!
    2. Re:bad omen by CptChipJew · · Score: 1

      That isn't necessarily true. It's just as possible people are wasting time fixing unimportant issues and ignoring more important ones.

      I'm not trying to disparage the OpenBSD team or anything. It's just that no development team is perfect.

      --
      Vonal Declosion
    3. Re:bad omen by exley · · Score: 5, Funny

      a 33 year old bug, plus a 25 year old bug (http://it.slashdot.org/article.pl?sid=08/05/11/1339228)....

      if we keep going backwards, will the world implode?

      Well since time began only 38.5 years ago we should find out the answer very soon!

    4. Re:bad omen by Anonymous Coward · · Score: 1, Insightful

      Just because I hate it when people do this:

      WHOOOOSH!!!

      Sorry about that...

    5. Re:bad omen by Dunbal · · Score: 3, Funny

      or will daemons start spewing out of cracks in time and space?

            I finally figured out what the UAC were doing on the Mars colony... and it had nothing to do with those artifacts!

            Thank god there's a division of Space Marines there...

      --
      Seven puppies were harmed during the making of this post.
    6. Re:bad omen by Dunbal · · Score: 4, Funny

      It's just as possible people are wasting time fixing unimportant issues and ignoring more important ones.

            We're talking programmers here, not politicians...

      --
      Seven puppies were harmed during the making of this post.
    7. Re:bad omen by p0tat03 · · Score: 2, Insightful

      Or we're so painfully slow with fixing bugs that we JUST got around to 1975 :P There are always multiple views :P

    8. Re:bad omen by K.+S.+Kyosuke · · Score: 4, Interesting

      First it was a fourth of a century, then it was a third of a century. The only logical consequence is that the next bug they will find now will be a memory leak in McCarthy's Lisp intepreter from '59 or some strange corner case in the Fortran I compiler. (Oh, and after a careful consideration, I am leaving the *next* bug as an exercise to the reader.)

      --
      Ezekiel 23:20
    9. Re:bad omen by cryptoluddite · · Score: 2, Funny

      Well since bugs before the epoch were actual insects, judging by past precedent they'll get super powers... like wall-climbing ability or maybe spidey senses ??

    10. Re:bad omen by menace3society · · Score: 4, Funny

      The next bug will be in Boolean logic. After that, OpenBSD devs will start fixing structural engineering errors the Tower of Pisa.

    11. Re:bad omen by incripshin · · Score: 3, Insightful

      Well, they're not checking yacc for bugs for the hell of it. They're reimplementing malloc to be more efficient, but it broke buggy code. Is there any other option than to fix yacc?

    12. Re:bad omen by Anonymous Coward · · Score: 0

      That's right. A good programmer knows to ignore both.

    13. Re:bad omen by Zencyde · · Score: 1

      Not a Snopes link but good enough: http://tafkac.org/faq2k/compute_86.html I'm sure there's a Snopes article on this that I'm too lazy to find. Now to put to rest this idea of "bugs" originating as actual bugs.

      --
      What day is it? Could you please tell me?
    14. Re:bad omen by Anonymous Coward · · Score: 0

      Actually, we're fixing bugs so fast that they're traveling back in time.

    15. Re:bad omen by Jurily · · Score: 4, Funny

      Sure. Break malloc even worse to allow for backwards compatibility.

      See "Windows 95".

    16. Re:bad omen by Nutria · · Score: 1

      Is there any other option than to fix yacc?

      Divorce is one way to "fix" constant yaccing.

      --
      "I don't know, therefore Aliens" Wafflebox1
    17. Re:bad omen by IcePic · · Score: 1

      Then again, the bug came up while failing to compile xulrunner, so it wasnt hunting for stupid 30+ years old code noone uses, but running a compile of something from this side of the millenium that in the end pointed to this bug.

      --
      -- I'm as unique as everyone else.
    18. Re:bad omen by Library+Spoff · · Score: 1

      They're using Vista on the Mars colony?

      Shurely shome mistake

      --
      Acid House saves Souls
    19. Re:bad omen by laejoh · · Score: 3, Funny

      In exactly 3.5 years , but I'm afraid the answer will disappoint you.

    20. Re:bad omen by Anonymous Coward · · Score: 1, Interesting

      Naw. But I was thinking that 25 and 33 years kind of puts Microsoft's End of Support Policy in perspective.

    21. Re:bad omen by skeeto · · Score: 1

      or will daemons start spewing out of cracks in time and space?

      Nope, they will just simply spew from our noses.

    22. Re:bad omen by Hatta · · Score: 1

      You are trying to activate the BFG 9000.

      Cancel or Allow?

      You are trying to frag a cyberdemon.

      Cancel or Allow?

      --
      Give me Classic Slashdot or give me death!
    23. Re:bad omen by mr_mischief · · Score: 1

      This is just a guess with no etymological (or entomological) evidence to back it up, but I've always wondered if "bug" wasn't from "bugbear" -- unseen mischievous forces which screw with how your stuff works.

      This would be as in the Merriam-Webster definition, particularly 2b: "a continuing source of irritation". Of course, 2a might sometimes fit: "an object or source of dread". Perhaps even definition 1 after along shift of maintenance work: "an imaginary goblin or specter used to excite fear".

    24. Re:bad omen by Anonymous Coward · · Score: 0

      Divorce is one way to "fix" constant yaccing.

      Divorce does little and might make things worse. The legal device your want is a restraining order.

    25. Re:bad omen by Anonymous Coward · · Score: 0

      a 33 year old bug, plus a 25 year old bug (http://it.slashdot.org/article.pl?sid=08/05/11/1339228)....

      if we keep going backwards, will the world implode? or will daemons start spewing out of cracks in time and space?

      Is that a saying of _the_ Oracle?

    26. Re:bad omen by Demodian · · Score: 1

      Actually, going back much further will get us into the days of vacuum tubes. Could be the Big Bang scientists are referring to all the time.

    27. Re:bad omen by Anonymous Coward · · Score: 0

      What happens when the bugs travel back to before 1970? If the epoch was defined as an unsigned variable, those bugs would wrap around and be sent Back to the Future!

  4. Great! by Anonymous Coward · · Score: 5, Interesting

    Any word on when they're going to fix the even older "Too many arguments" bug?

    Sorry, but any modern system where a command like "ls a*" may or may not work, based exclusively on the number of files in the directory, is broken.

    1. Re:Great! by The+Master+Control+P · · Score: 5, Funny

      I too was devastated to learn that my poor Linux box can only handle 128KB of command line arguments. How can I possibly finish typing in that uncompressed bitmap...

    2. Re:Great! by Dadoo · · Score: 4, Informative

      While I'm sure you're trolling, I feel I should point out that, 1) I agree with you, and 2) this has apparently been fixed, on Linux:

              http://agnimidhun.blogspot.com/2007/08/vi-editor-causes-brain-damage-ha-ha-ha.html

      --
      Sit, Ubuntu, sit. Good dog.
    3. Re:Great! by Dunbal · · Score: 1

      128k should be enough for anyone.

      --
      Seven puppies were harmed during the making of this post.
    4. Re:Great! by Anonymous Coward · · Score: 0

      A better example is everyone's favorite:

      find /usr -type f | xargs grep foo

      It's really annoying knowing you can't use this in a crontab script because it might fail.

    5. Re:Great! by Malevolyn · · Score: 1

      Some of us require, maximum, 640k.

      --
      Your ad here.
    6. Re:Great! by Craig+Davison · · Score: 4, Interesting

      If "ls a*" isn't working, it's because the shell is expanding a* into a command line >100kB in size. That's not the right way to do it.

      Try "find -name 'a*'", or if you want ls -l style output, "find -name 'a*' -exec ls -l {} \;"

    7. Re:Great! by GuyverDH · · Score: 1

      it was fixed years ago....

      find . -name "a*" -prune -exec ls -ld {} \;

      (note: this command line was generated by reading the man page for gnu find - may not work on all unix/linux variants)

      --
      Who is general failure, and why is he reading my hard drive?
    8. Re:Great! by Anonymous Coward · · Score: 0

      I have no sympathy for you. If you exceed the 128k on the command line, you're doing it wrong. And if this problem causes you grief, then you've no business on the command line.

    9. Re:Great! by Anonymous Coward · · Score: 0

      Well, strictly speaking the limit isn't exclusively the number of files. It's a combination of filename length and number of files.

    10. Re:Great! by Anonymous Coward · · Score: 2, Interesting

      So, as an example, let's say I want to archive a bunch of files, then remove them from my system, to save space. I packed them up, using:

              tar cf archive.tar dir1 dir2 file1 file2 file3

      and, because I'm extremely paranoid, I only want to delete files I'm sure are in the archive. How would I do that? Could I use:

              rm `tar tf archive.tar`

      How about:

              tar tf archive.tar | xargs rm

      I'm pretty sure neither of those will work in all cases. The first will fail if there are more than a few thousand files in the archive, and the second will fail if the files in the archive contain spaces or special characters. Can you give me one command that will work in all cases?

    11. Re:Great! by Anonymous Coward · · Score: 0
      find /usr -type f | xargs grep foo

      Works with the GNU versions of these tools (eg on every Linux distribution):
      find /usr -type f -print0 | xargs -0 grep foo

    12. Re:Great! by Jeffrey+Baker · · Score: 1

      Actually, a patch was recently added to Linux to dynamically allocate the command line, so your argument length is now bounded only by available memory.

    13. Re:Great! by drinkypoo · · Score: 2, Informative

      Instead of "ls a*"? Seriously? Hopefully, someone will mod you funny.

      Unix has extremely low overhead spawning processes. If you prelink and have a little cache this is plenty fast :P

      Seriously though, this is a serious annoyance in the way Unix does business. Shell globbing is very convenient for programmers, but not so convenient for users in an awful lot of situations.

      --
      "You're right," Fisheye says. "I should have set it on 'whip' or 'chop.'"
    14. Re:Great! by Lord+Kano · · Score: 1

      Sorry, but any modern system where a command like "ls a*" may or may not work, based exclusively on the number of files in the directory, is broken.

      Have you ever tried to get the contents of a directory on NT* when there are a buttload of files in it?

      We encountered that a few months ago at work. A few hundred thousand log files in a single directory is not a good thing.

      LK

      --
      "Hi. This is my friend, Jack Shit, and you don't know him." - Lord Kano
    15. Re:Great! by Anonymous Coward · · Score: 0

      You sure that would be an OS patch? Wouldn't that be something the bash/csh/ksh/whatever-shell maintainers would be responsible for?

    16. Re:Great! by The+Master+Control+P · · Score: 1

      Have a script loop over your directories, adding them to the archive before firing the Are-Em Star at them.

      /The power to destroy an entire filesystem is insignificant next to the power of the Farce

    17. Re:Great! by menace3society · · Score: 4, Funny

      Burn the contents of the tar archive onto a CD. Mount the CD over the original directory structure. Use find(1)'s -fstype option to locate all the files that aren't on the CD, copy them to an empty disk image, then eject the CD. Remount the disk image over the original directory, delete all the files in the directory, then unmount the disk image. The files identical in name to those that were on the disk image (which are those that weren't on the CD) won't be deleted thanks to the peculiarities of mount(2).

      You're welcome.

    18. Re:Great! by Just+Some+Guy · · Score: 4, Informative

      if you want ls -l style output, "find -name 'a*' -exec ls -l {} \;"

      Yeah, because nothing endears you with the greybeards like racing through the process table as fast as possible. Use something more sane like:

      $ find -name 'a*' -print0 | xargs -0 ls -l

      which only spawns a new process every few thousand entries or so.

      --
      Dewey, what part of this looks like authorities should be involved?
    19. Re:Great! by Jeffrey+Baker · · Score: 4, Informative

      It's both. The kernel is responsible for setting up the execution environment, and in the past it used a fixed 32 pages for the arguments. 32 pages on an ordinary PC is 128KiB, which is the old limit. The new limit is that any one argument can be up to 32 pages, and all the arguments taken together can be 0x7FFFFFFF bytes, which is ~2GiB.

      Here's the diff: http://git.kernel.org/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commitdiff;h=b6a2fea39318e43fee84fa7b0b90d68bed92d2ba;hp=bdf4c48af20a3b0f01671799ace345e3d49576da

      After that, it was up to libc people to fix the globbing routines. Ulrich Drepper, taking some time off from his full-time job of being an asshole on mailing lists, managed to work this into glibc 2.8:

      http://sourceware.org/ml/libc-alpha/2008-04/msg00050.html

    20. Re:Great! by rakslice · · Score: 1

      heh... FWIW on Windows people are stuck with only a few kB of command line and no shell wildcard expansion at all, and they don't seem to be crying in their beers (... it's the market leader last time I checked)

      The (not-so-)secret is to not do things by passing big lists around using command line arguments. Back in unix land, you can do glob-filtered listings like the one you suggested with the find command. And even the basic commands like ls can take parameters via xargs instead of regular command line arguments. (As always, see the find and xargs manual pages for more information.)

    21. Re:Great! by QuoteMstr · · Score: 2, Informative

      On modern systems, find -name 'a*' -exec ls -l {} +

      Personally, however, I prefer find -name a\* -exec ls -l {} +

      Also, you probably want to add a -type f before the -exec, unless you also want to list directories.

      Either that, or make the command ls -ld to not list the contents of directories.

    22. Re:Great! by evilviper · · Score: 2, Informative

      I only want to delete files I'm sure are in the archive. How would I do that?


      tar tf archive.tar | while read FILENAME ; do
          rm "$FILENAME"
      done

      --
      Slashdot gets worse every day... Pipedot: News for nerds, without the corporate slant
    23. Re:Great! by Anonymous Coward · · Score: 0

      Actually, not quite. It will trim spaces at the start and end of lines, so you need to set IFS="" and use "read -r".

      Pathologically, it won't handle newlines in file names, which are valid in Unix.

      There's probably yet more bugs in such a short piece of code.

    24. Re:Great! by just_another_sean · · Score: 1

      How about:

      for f in `tar tf archive.tar`; do
            rm $f
      done

      --
      Creationist Textbook Stickers Declared Unconstitutional by CowboyNeal
    25. Re:Great! by Anonymous Coward · · Score: 0

      Or why not simply

        $ find -name 'a*' -ls

    26. Re:Great! by MBGMorden · · Score: 2, Funny

      You forgot "Er.". All Linux advice must contain "Er." at the beginning of the first sentence in order to signify the fact that the poster should have already known how to do this rather than asking this question.

      --
      "People who think they know everything are very annoying to those of us who do."-Mark Twain
    27. Re:Great! by maztuhblastah · · Score: 3, Funny

      So Saturdays at your house must be a real blast, huh?

    28. Re:Great! by ak3ldama · · Score: 2, Interesting

      Seems to me that he is allowed to be an asshole occassionally as long as he can share this kind of information.

      --
      "but money is the God of Algiers & Mahomet their prophet." - Rich. O'Bryen June 8th 1786
    29. Re:Great! by Burning1 · · Score: 1

      Psudo code, because my geekhood isn't threatened by petty things like the need for debugging and syntax checks:

      tar tf archive.tar > /tmp/archive.txt
      ls dir1 dir2 file1 file2 file3 > /tmp/tree.txt
      diff /tmp/archive.txt /tmp/tree.txt > /tmp/delta.txt
      rm /tmp/delta.txt

    30. Re:Great! by Burning1 · · Score: 1

      It is threatened by the lack of < signs, however. That's supposed to read:
      rm < /tmp/delta.txt

    31. Re:Great! by Anonymous Coward · · Score: 0

      Okay, here it goes: I tested with directories (you can change this to rm to catch filenames, etc.) with newlines and spaces. Please test with other special characters and you may need to tweak slightly for all cases. Hopefully this will get you on the right track though.

      tar tf test.tar | tr '\n' '\0' | xargs -I '{}' - -n -e '{}\0' | xargs -0 rmdir

      Note: I had single ticks between {} and \0 but the slashdot comment box kept trying to combine them into double quotes.

      http://training-sites.wik.is/User:David_Duffey

    32. Re:Great! by Duffey · · Score: 1

      Most of the suggestions here are too simplistic and don't understand the nature of the problem.

      Another option wound be to use find with "-print0" and then tar the result of that by passing --null to tar AND passing it to xargs -0 rm.

      This would certainly be more strait-forward than the command I posted above.

    33. Re:Great! by GuyverDH · · Score: 1

      or an even shorter solution...

      ls -c1 | grep "^a"

      and if you wanted upper and lower-case a files,

      ls -c1 | grep -i "^a"

      --
      Who is general failure, and why is he reading my hard drive?
    34. Re:Great! by James+Youngman · · Score: 1

      Yuck. Much more efficient: find . -name 'a*' -ls

    35. Re:Great! by Wodin · · Score: 1

      You could try:

      tar tf archive.tar | while read fname; do rm "${fname}"; done

      but that will break if you have newlines (and probably other non-printable characters) in your filenames.

      --
      -- Wodin
    36. Re:Great! by jandrese · · Score: 1

      Yeah, a great many shells scripts can be done in by simply putting spaces in your filenames. The builtin unix tools just handle spaces poorly.

      --

      I read the internet for the articles.
    37. Re:Great! by Anonymous Coward · · Score: 0

      or find -ls

    38. Re:Great! by tirnacopu · · Score: 2, Informative

      Jesus F Christ people, did you just list 50 different ways of enumerating the files in a directory, all of them using a single platform (Linux + bash), all of them riddled with bugs due to whitespace, other special characters the shell might interpret, plus Unicode where applicable - and none of you considers there might be some issue with it?

    39. Re:Great! by GuyverDH · · Score: 1

      uhm - no...
      the ls entries listed above work perfectly well on Solaris, AIX, HP-UX and Linux.

      ksh is the only shell I use, although I'm sure it would work with bash.

      I primarily work on Solaris (SPARC/x86/x64) platforms - I won't go into any kind of flame wars over it, it's just what my company uses primarily.

      --
      Who is general failure, and why is he reading my hard drive?
    40. Re:Great! by Anonymous Coward · · Score: 0
      I got tired of this issue years ago and have taken to doing stuff like:

      export IFS="<press enter>" && for i in *.xyz; do rm $i; done

      I never did figure out how to embed the enter character other than just hitting enter right after the first quote and then immediately closing the quote.

    41. Re:Great! by menace3society · · Score: 1

      You're just jealous you couldn't think of something so simultaneously clever and over-involved.

    42. Re:Great! by zentigger · · Score: 1

      foreach file ( a* )
      echo $file
      end

      --

      the above is my personal opinion and does not necessarily reflect that of the little voices in my head

  5. maybe it's just me by Anonymous Coward · · Score: 1, Interesting

    But this code just seems wrong. What is C code doing referencing the stack pointer directly?

    1. Re:maybe it's just me by DogAlmity · · Score: 1

      A stack pointer, not THE stack pointer. Just the generic data structure from CS 201.

    2. Re:maybe it's just me by Zero__Kelvin · · Score: 1

      "What is C code doing referencing the stack pointer directly?"

      Because it is C, and C is designed to be able to do so? How do you think the Linux kernel gets implemented, though it also has Assembly to be sure. C was designed to allow implementation of Operating Systems. The capability to reference the Stack Pointer and do other assemblyie things via the asm keyword is part of its charm ;-)

      --
      Guns don't kill people; Physics kills people! - John Lithgow as Dick Solomon on Third Rock From The Sun
  6. No, damn by Nimey · · Score: 0, Redundant

    Damn. Ignore that, it's a different ancient Unix bug.

    --
    Hail Eris, full of mischief...

    E pluribus sanguinem
    1. Re:No, damn by MichaelSmith · · Score: 1

      Lets have a BSD article for every bug in lex and yacc.

  7. Yeah, it's probably you. by Estanislao+Mart�nez · · Score: 3, Informative

    I bet you they're not talking about the system stack pointer. Remember, yacc is a parser generator; parsing algorithms always use some sort of stack data structure. So, the "stack pointer" in question is just a plain old pointer, pointing into a stack that yacc's generated code uses.

    1. Re:Yeah, it's probably you. by Anonymous Coward · · Score: 1, Informative

      Exactly. The code:yym = yylen[yyn];
      yyval = yyvsp[1-yym];

      This is one of the reasons that I hate C code (but I love it most of the time). If your stack was an object (preferably a STL vector), bugs like this wouldn't arise in a way that they could be exploited (your program would instead terminate with an uncaught exception that would point you exactly where your bug was).

    2. Re:Yeah, it's probably you. by Skrapion · · Score: 2, Informative

      Actually, the [] operator of an STL vector doesn't throw any exceptions, and will happily allow you to reference an index which is out of bounds.

      That's not a bad thing, because it's more efficient when you already know that your index is in rage. But if you don't know that, you're better off using the at() function.

      --
      The details are trivial and useless; The reasons, as always, purely human ones.
    3. Re:Yeah, it's probably you. by tomhudson · · Score: 1

      There's a bug in the explanation.

      From the linky (emphasis mine):

      yypv =- yyr2[n];
      yyval=yypv[1];
      access an item above the stack pointer. If yyr2[n] is zero, this is a potential access outside the stack. Note the archaic use of =-, we write -= these days.

      "-=" is NOT the same as "=-".

      Example:

      #include <stdio.h>
      #include <stdlib.h>

      int main(int argc, char* argv[], char* env[]) {
      int a=10;
      int b=10;

      a =- 5;
      b -= 5;printf("a=%d, b=%d\n", a, b);

      return EXIT_SUCCESS;
      }

      returns a=-5, b=5

      BIG difference.

    4. Re:Yeah, it's probably you. by trb · · Score: 1

      No, it's probably you. In days of old, C's =- operator was equivalent to its present-day -= operator, as is clearly shown in the example. For conclusive evidence, see Dennis Ritchie's article, The Development of the C Language. See the section headed "More History." It discusses =+, which was a sibling of =- . Ritchie says it was fixed in 1976 (by allowing +=), but I remember compilers also accepting the deprecated =- until 1980 or so.

    5. Re:Yeah, it's probably you. by EvanED · · Score: 1

      Actually, the [] operator of an STL vector doesn't throw any exceptions, and will happily allow you to reference an index which is out of bounds.

      It's entirely possible that your STL implementation IS doing bounds checking on [] when doing debug releases, which means that if you do testing under a debug build, you're more likely to find problems even if you use [], so you're still in better shape than if you had used arrays.

      For instance, the following program compiled with Visual Studio 2008 under release mode performs an illegal operation (I don't really understand why it does, but it does), but under debug build fails an assertion that says "vector subscript out of range".

      #include <iostream>
      #include <vector>
       
      using namespace std;
       
      int main()
      {
          vector<int> v;
          v.reserve(10);
          v[0] = 5;
       
          cout << v[0] << endl;
      }

      GCC doesn't seem to do this, but I only tried under Cygwin and could be mistaken.

      (I also tend to think that the bounds checking properties of [] and at() should be reversed, but that's just me. I think that 95% of the time you should include checking, and [] is easier to read, more natural, and fits better with templates than at().)

    6. Re:Yeah, it's probably you. by setagllib · · Score: 2, Informative

      Best of all, even if you use assert() (or similar) for really explicit bounds checking, GCC will omit it from code paths where it's deemed to be unused. So if your accesses are being inlined (and if they're not, take a long hard look at your life) then the already-safe paths won't have the check overhead even in a debug build.

      Yes, I've tested it. Yes, it's impressive.

      --
      Sam ty sig.
    7. Re:Yeah, it's probably you. by EvanED · · Score: 1

      For instance, the following program compiled with Visual Studio 2008 under release mode performs an illegal operation (I don't really understand why it does, but it does)

      Figured it out.

      Even under release builds, VS will by default do range checks on []. (This *is* allowed by the C++ standard, even if it's a little outside of the spirit.)

      Adding the following to the top of the file:

      #define _SECURE_SCL 0

      (see here) will cause it to run to completion, with "5" as the output.

    8. Re:Yeah, it's probably you. by tomhudson · · Score: 4, Informative

      From the link you cited:

      By 1971, our miniature computer center was beginning to have users. We all wanted to create interesting software more easily. Using assembler was dreary enough that B, despite its performance problems, had been supplemented by a small library of useful service routines and was being used for more and more new programs. Among the more notable results of this period was Steve Johnson's first version of the yacc parser-generator [Johnson 79a].

      The code for yacc was certainly not originally written in c - c didn't exist at that time.

      In 1978 Brian Kernighan and I published The C Programming Language [Kernighan 78]. Although it did not describe some additions that soon became common, this book served as the language reference until a formal standard was adopted more than ten years later.

      The "archaic behaviour" was never part of that standard - it was a mistake in early implementations while they were still "working out the details" of the language, well before K & R, as Ritchie says:

      After the TMG version of B was working, Thompson rewrote B in itself (a bootstrapping step). During development, he continually struggled against memory limitations: each language addition inflated the compiler so it could barely fit, but each rewrite taking advantage of the feature reduced its size. For example, B introduced generalized assignment operators, using x=+y to add y to x. The notation came from Algol 68 [Wijngaarden 75] via McIlroy, who had incorporated it into his version of TMG. (In B and early C, the operator was spelled =+ instead of += ; this mistake, repaired in 1976, was induced by a seductively easy way of handling the first form in B's lexical analyzer.)

      It wasn't an archaism in c - it was an archaism from b that was removed during the development of what became c. Small difference, and for all practical purposes, it gives the same result - previously-working code that wasn't reviewed as the language evolved towards a standard ended up with "implementation-dependent behaviour" - bugs ... The worst part is that the buggy code is syntactically correct, so no compiler warnings. Of course, if your conforming compiler doesn't give a warning, you assume that the code written with the experimental versions is still valid.

    9. Re:Yeah, it's probably you. by Anonymous Coward · · Score: 0

      Early C is still C, and it was an archaic form of that operator in C, surviving from B. But note the dates: It was fixed in 1976, but the bug appears in the source that was released in 1975.

    10. Re:Yeah, it's probably you. by EvanED · · Score: 1

      The code for yacc was certainly not originally written in c - c didn't exist at that time.

      Then why are you using C code to illustrate the behavior of code that wouldn't have been in C?

      By 1975, either Yacc was written in C or it wasn't. If it wasn't, then your example is irrelevant anyway. If it was in C, then you'll note that =+ was changed to += in 1976, but this bug was in the 1975 version. Ergo, the bug was in the (preliminary) version of C that Yacc was using.

      The "archaic behaviour" was never part of that standard - it was a mistake in early implementations while they were still "working out the details" of the language, well before K & R, as Ritchie says:

      That's fine. But Yacc was still written in that early version.

    11. Re:Yeah, it's probably you. by OttoM · · Score: 1
      You should de some background research on the history of C.

      In the early 70's, a new language evolved from B. In these years, the new language was evolving quickly, but by 1973, it was mature enough to allow the Unix kernel to be rewritten in it. The makers called it C, from the same article:

      By early 1973, the essentials of modern C were complete.

      Who are you to say that it wasn't C?

      And for certain, the yacc included in V6 was written in C, it generated C and it would soon be used to write C compilers.

  8. Semi-OT by pxc · · Score: 0, Offtopic

    Does anyone know if there's a way to make bsd.slashdot.org show up as a section on the main lefthand menu?

    1. Re:Semi-OT by Anonymous Coward · · Score: 0

      Yes

  9. Was it really a bug back then? by Just+Some+Guy · · Score: 4, Interesting

    Was this a bug when it was originally written, or is it only because of recent developments that it could become exploitable? For instance, the summary mentions stack size. I could imagine that a system written in 1975 would be physically incapable of the process limits we use today, so maybe the program wasn't written to check for them.

    Does your software ensure that it doesn't use more than an exabyte of memory? If it doesn't, would you really call it a bug?

    --
    Dewey, what part of this looks like authorities should be involved?
    1. Re:Was it really a bug back then? by QuantumG · · Score: 5, Insightful

      If you overflow a buffer then it's a bug, whether it is exploitable or not.

      --
      How we know is more important than what we know.
    2. Re:Was it really a bug back then? by jd · · Score: 2, Informative
      It would have been a bug, but not necessarily one that would have security implications, though that could be system-dependent. The summary mentions a specific malloc was used to get a segfault. Another malloc library may well not have faulted. That would only matter if it was possible via the buffer overflow to get yacc to do something (such as run your code) with privileges other than those you would ordinarily have had.

      Now, looking at it just as a bug, if the yacc script overflowed the buffer, yacc can either stop cleanly or crash untidily. It has the same effect - nothing much happens - unless, for some weird reason, the kernel holds onto the memory. That would be a kernel bug, though, the yacc bug would merely be a catalyst for exposing it.

      --
      It's a small world and it smells funny; I'd buy another if it wasn't for the money; Take back what I paid (SoM)
    3. Re:Was it really a bug back then? by russlar · · Score: 5, Funny

      If you overflow a buffer then it's a bug, whether it is exploitable or not.

      If you can overflow an exabyte-sized memory buffer, you deserve a fucking medal.

      --
      Anybody want my mod points?
    4. Re:Was it really a bug back then? by Just+Some+Guy · · Score: 2, Interesting

      If you overflow a buffer then it's a bug, whether it is exploitable or not.

      It is today, but my questions is whether it was even overflowable (is that a word?) when it was written. For example, suppose it was written for a 512KB machine and had buffers that could theoretically hold 16MB, then it wasn't really a bug. The OS itself was protecting the process by its inability to manage that much data, and it wouldn't have been considered buggy to not test for provably impossible conditions.

      I'm not saying that's what happened, and maybe it really was just a dumb oversight. However, I think there's a pretty strong likelihood that it was safe to run in the environment where it was written, and the real bug was in not addressing that design characteristic when porting it to a newer platform.

      See also: Ariane 5. Its software worked great in the Ariane 4, but had interesting behavior when dropped into a faster system.

      --
      Dewey, what part of this looks like authorities should be involved?
    5. Re:Was it really a bug back then? by QuantumG · · Score: 1

      Failure to check for a buffer overflow is an error. It doesn't matter if someone else will do it for you and, as such, the error will never result in a problem for someone. It's simply wrong.

      --
      How we know is more important than what we know.
    6. Re:Was it really a bug back then? by JoshJ · · Score: 1

      int *buffer; /*Pointer to exabyte-sized buffer*/

      while(1){
        *buffer=1;
        buffer++;
      }

      /*Where's my medal?*/

    7. Re:Was it really a bug back then? by AJWM · · Score: 4, Funny

      /*Where's my medal?*/

      You'll get it when the buffer overflows. If you're running it on a system that processes a billion of those loops per second, that should be in a bit over 31 years. Scale accordingly for your processor and memory speed.

      --
      -- Alastair
    8. Re:Was it really a bug back then? by Anonymous Coward · · Score: 0

      Too long. I want my medal in a month using a 1 MHz processor...

      while (1) *(buffer += 31*12*1000) = 1;

    9. Re:Was it really a bug back then? by robthebloke · · Score: 1

      That'll all depend on the speed of your ram....

    10. Re:Was it really a bug back then? by Gazzonyx · · Score: 1

      If you overflow a buffer then it's a bug, whether it is exploitable or not.

      If you can overflow an exabyte-sized memory buffer, you deserve a fucking medal.

      *insert emacs joke here*

      --

      If I mod you up, it doesn't necessarily mean I agree with what you've said, sorry.

    11. Re:Was it really a bug back then? by Fzz · · Score: 1
      /*Where's my medal?*/

      Unless you're running on pretty rare 64-bit hardware, an int will still only be 32 bits. I can't remember what happens when you overflow 2^31 and try to de-reference a negative pointer (probably it just implicitly casts to unsigned), but you sure aren't going to overflow an exabyte buffer that way.

    12. Re:Was it really a bug back then? by JoshJ · · Score: 1

      You're right, unsigned long would have been a better choice.

    13. Re:Was it really a bug back then? by phantomcircuit · · Score: 1

      char *buffer; while(1) { buffer = buffer * buffer; buffer[buffer*buffer] = 0; } I can haz medal?

  10. Other Unixes by jasonmanley · · Score: 2, Interesting

    Forgive me if this is obvious but if the bug goes that far back will it not affect all other unixes that are based on this same source code - not just OpenBSD?

    --
    http://projectleader.wordpress.com
    1. Re:Other Unixes by X0563511 · · Score: 5, Informative

      Yes. But OpenBSD fixed it, so they get credit for the fix. It's up to the maintainers of the other unix(ish) versions to implement the fix.

      --
      For large sets, this will be our guide even unto death, for the LORD will work for each type of data it is applied to...
  11. Re:And Next Week by Pazy · · Score: 0, Redundant

    Sorry that message was me, didnt seem to want to keep me signed in :|

  12. Re:And Next Week by X0563511 · · Score: 1

    Sorry that message was me, didnt seem to want to keep me signed in :|

    --
    For large sets, this will be our guide even unto death, for the LORD will work for each type of data it is applied to...
  13. Re:And Next Week by Anonymous Coward · · Score: 0

    Sorry that message was me, doesn't seem to want to keep me signed in :|

  14. (modern_system != infinite_memory) by Zero__Kelvin · · Score: 1, Interesting

    "Sorry, but any modern system where a command like ls "a*" may or may not work, based exclusively on the number of files in the directory, is broken."

    It is not broken. The fact that it complains "too many arguments" is evidence that it is not broken, since the program (ls) is doing bounds checks on the input. If it was broken, you wouldn't get the message; there would be a buffer overflow because the programmer didn't do constraints checking.

    --
    Guns don't kill people; Physics kills people! - John Lithgow as Dick Solomon on Third Rock From The Sun
  15. Re:You do realize.. by vbraga · · Score: 1, Informative

    Mod parent -1 Bullshit.

    yacc is not a compiler, go read the link you posted.

    This links to what you probably means, but yacc has nothing to do with it.

    --
    English is not my first language. Corrections and suggestions are welcome.
  16. Re:You do realize.. by QuantumG · · Score: 4, Informative

    yacc is not a compiler,

    Excuse me?

    Yet Another Compiler Compiler most definitely is a compiler.

    --
    How we know is more important than what we know.
  17. ERRATA by Zero__Kelvin · · Score: 2, Insightful

    I'll catch myself before someone else does. Everything I said above is true, except that ls isn't complaining. The OS, specifically exec() and friends, is complaining because the command line length when the shell expands the wildcard exceeds ARG_MAX. Increase ARG_MAX if you want to allow more files, or use a variation of find with the -exec option or xargs, etc.

    --
    Guns don't kill people; Physics kills people! - John Lithgow as Dick Solomon on Third Rock From The Sun
  18. Re:You do realize.. by vbraga · · Score: 1

    Sorry, I'm not a native speaker. Not a C compiler, as GP said.

    --
    English is not my first language. Corrections and suggestions are welcome.
  19. Note to Self... Core memory by gearloos · · Score: 1

    Note to self: Don't worry about having that extra 2k of core memory as the buffer overrun does not work anymore. Sweet.

    --
    "Computers are a lot like Air Conditioners" "They both work great until you start opening Windows"
  20. Re:You do realize.. by menace3society · · Score: 1

    Mod parent -1 Horseshit.

    yacc is a compiler, what do you think the two c's stand for?

  21. Re:You do realize.. by wb8wsf · · Score: 4, Informative

    OpenBSD still uses GCC, version 3.3.5 on i386. I can't say which version is used on the other platforms.

    You are talking of PCC, which is being worked on by some of the OpenBSD developers, but I think its a parallel project, see http://pcc.ludd.ltu.se/
    for more information.

    Jem Matzen talked of this too, see http://www.thejemreport.com/mambo/content/view/369/

  22. Re:You do realize.. by incripshin · · Score: 4, Interesting

    gcc still is the default. pcc isn't ready yet, and I don't expect it to be for at least a couple years, and I say that with zero confidence (I'm just an OpenBSD user; I have no idea how the progress is going on pcc).

  23. Re:And Next Week by setagllib · · Score: 1

    Sorry that ^U I am Spartacus.

    --
    Sam ty sig.
  24. Hilarious! by BollocksToThis · · Score: 5, Funny

    Funny thing is that I traced this back to Sixth Edition UNIX, released in 1975

    My sides are completely split! Invite this guy to more parties.

    --
    This sig is part of your complete breakfast.
  25. The Problem is *why* it's the wrong way to do it by billstewart · · Score: 3, Interesting

    You're correct that's it's not the right way to do it. The problem is *why* it's not the right way to do it. It's not the right way to do it because the arg mechanism chokes on it due to arbitrary limits, and/or because your favorite shell chokes on it first, forcing you to use workarounds. Choking on arbitrary limits is a bad behaviour, leading to buggy results and occasional security holes. That's separate from the question of whether it's more efficient to feed a list of names to xargs or use ugly syntax with find.

    Now, if you were running v7 on a PDP-11, there wasn't really enough memory around to do everything without arbitrary limits, so documenting them and raising error conditions when they get exceeded is excusable, and if you were running on a VAX 11/780 which had per-process memory limits around 6MB for some early operating systems, or small-model Xenix or Venix on a 286, it's similarly excusable to have some well-documented arbitrary limits. But certainly this stuff should have been fixed by around 1990.

    --

    Bill Stewart
    New Fast-Compression-only CPR http://preview.tinyurl.com/dy575ks
  26. Bringing down the product for ones own fame by nikanth · · Score: 1

    Will any proprietary business be ready to accept that their product had a bug for the past 3 decades which was identified only now? Does this mean the community is not very active? But somehow this do not seem to bring negative impact in the minds of people as most of the open source consumers know that this means that even the old code is continuously tuned and open source guys have realistic sensible expectations.

  27. Fixed in Linux by blitzkrieg3 · · Score: 1

    Any word on when they're going to fix the even older "Too many arguments" bug?

    Use linux instead.
    CHANGELOG
    git commit

  28. In Defense of Limits by QuoteMstr · · Score: 2, Interesting

    Soft limits can actually mitigate bugs. If we limit processes by default to 1,024 file descriptors, and one of them hits the limit, that process probably has a bug, and would have brought the system to its knees had it continued to allocate file descriptors. Programs designed to use more descriptors could to increase the limit.

  29. Re:You do realize.. by Anonymous Coward · · Score: 0

    Yet Another Compiler Compiler most definitely is a compiler.

    While it may be, it's not something you use to compile your everyday programs with and it's certainly not something OpenBSD uses instead of GCC (they will most likely use PCC when it's gets to an acceptable level).

    - Peder

  30. Re:You do realize.. by Anonymous Coward · · Score: 0

    Meh, the pcc project was a stupid idea anyway. A modern optimizing multi-platform C compiler is complicated as shit (let alone C++), they have no clue what is ahead. Hell, look at TinyCC, it's not so tiny any more and is not optimizing nor multi-platform.

  31. Re:You do realize.. by larry+bagina · · Score: 1

    I'm wondering why they'd go with pcc over llvm. llvm is under a BSD-like license and actively being developed (by Apple as well as others).

    --
    Do you even lift?

    These aren't the 'roids you're looking for.

  32. Re:You do realize.. by Anonymous Coward · · Score: 0

    Uhh... It generates C parser code for the grammar you specify. It does not generate assembly language code, perform optimisations, type checking etc., that you expect from a compiler. Lets just stick with its proper name shall we? Its a parser generator. It creates a compiler compiler from the grammar you give.

  33. Re:You do realize.. by geminidomino · · Score: 1

    Alternate and equivalent volume to 1 ml?

  34. Coincidence? by the_arrow · · Score: 1

    I just finished reading the "The A-Z of Programming Languages" series on Computerworld (found out about it in here), and now the next article in the series just came up and it's a chat with the creator of Yacc.
    Coincidence?

    And for those that want to read the interview, it can be found here.

    --
    / The Arrow
    "How lovely you are. So lovely in my straightjacket..." - Nny
  35. New tagline for OpenBSD by kriston · · Score: 1

    Only two or three remote holes in the default install not from 33 years ago, in more than 10 years but not less than 33 years!

    --

    Kriston

  36. Sane limits by Jeppe+Salvesen · · Score: 1

    While xargs is a great little workaround/workhorse, it is needed in far too many cases. Why on earth would it be so hard to increase the limits every once in a while? After all, the limit in question was probably perfectly acceptable back in the day when 20mb was a lot of space and 500 files was more files than you could imagine ever creating.

    --

    Stop the brainwash