Take a gander at Fixing seekdir(), an account of quashing a bug in the BSD directory libraries. This is a very interesting piece of UNIX history, and probably still exists in the most recent versions of Apple's OSX.
My favorite part?
=========================== 4.1 c.1 ======================================= /* Copyright (c) 1982 Regents of the University of California */
That's right — this bug has been lurking since 1982.