[Toybox] fdlength bug

Rob Landley rob at landley.net
Wed Aug 7 21:02:12 PDT 2013


On 07/31/2013 08:11:09 AM, Achille Fouilleul wrote:
> Hello,
> 
> fdlength in lib.c does not seem to work properly, I noticed this when
> toybox's insmod sometimes failed mysteriously.

Sigh. I screwed up a simple binary search.

What I should really do is stat the file, if it's a regular file do the  
lseek(SEEK_END) thing. Where that _fails_ is on block devices (cdrom  
especially). While I hate to have multiple codepaths, that is the  
common case.

(This was originally for mke2fs, but I started using it everywhere  
since it was already there. Sometime between 2006 and the project's  
relaunch in 2011, I forgot I hadn't done the right common case  
fallback...)

> I have attached a patch that should fix the issue, along with a test  
> case
> that evidences the issue (use -std=c99).

Or just move the one declaration from the for loop to the start of the  
function.

Thanks for the heads up, I'll fix it.

Rob
 1375934532.0


More information about the Toybox mailing list