Title : The 25 Year Old BSD Bug

 
Date : 2008-05-12 
Code : 
1983. The year of the <a href="http://en.wikipedia.org/wiki/IBM_PC_XT">IBM PC XT</a>, the <a href="http://en.wikipedia.org/wiki/Apple_Lisa">Apple Lisa</a>, <a href="http://en.wikipedia.org/wiki/Pioneer_10">Pioneer 10</a> leaving the solar system, and <a href="http://en.wikipedia.org/wiki/Hooters">Hooters</a> opening up shop in Florida. It's also the birthyear of a 25 year old BSD bug, <a href="http://www.vnode.ch/fixing_seekdir">squashed only a few days ago</a>.
<br /><br />A few days ago, Marc Balmer, OpenBSD developer, received an email from an OpenBSD user. The email claimed that SAMBA would crash when serving files off an MS-DOS filesystem. Balmer got into contact with a few SAMBA developers who claimed that SAMBA uses a special workaround in order to function properly on BSD systems: the code for reading directories in <i>all</i> BSDs was flawed.
</p><p>
Understandably, Balmer's first reaction was disbelief. <i>"Of course my first reaction was to blame Samba,"</i> he writes. Despite his initial reaction, he decided to dig deeper into this case, and he uncovered a bug that had been sitting in the code of all BSDs (including Mac OS X), including a lot of old releases. He confirmed the bug was already in 4.2BSD, released in August of <i>1983</i>.
</p><p>
The bug itself? Well, I'm no programmer so the actual code is kind of gibberish to me, but I think I get the gist of the problem.
<p></p>
<div class="cquote">This code will not work as expected when seeking to the second entry of a block where the first has been deleted: seekdir() calls readdir() which happily skips the first entry (it has inode set to zero), and advance to the second entry. When the user now calls readdir() to read the directory entry to which he just seekdir()ed, he does not get the second entry but the third.
			
 
# securitydot.net Sun, 07 Sep 2008 09:33:50 +0000