[Toybox] ls segfault

Rob Landley rob at landley.net
Thu Jul 4 05:23:52 PDT 2013


On 06/29/2013 04:11:26 PM, Felix Janda wrote:
> ls segfaults if there is only one file to display.

And /dev/tty reports a screen size of 0,0.

> The problem seems to be:
> 
> static void listfiles(int dirfd, struct dirtree *indir)
> {
> ...
>   for (ul = 0; ul<dtlen; ul++) {
>     unsigned curcol;
> ...
>     // Pad columns
>     if (flags & (FLAG_C|FLAG_x)) {
>       curcol = colsizes[curcol] - *len;
>       if (curcol >= 0) xprintf("%s", toybuf+255-curcol);
>     }
> ...

I actually found and fixed this already, but thanks for the report. (I  
need to work out how to fake tty stuff for the test suite. When  
/dev/tty reports a nonzero size, even "ls -C < /dev/null 2>/dev/null |  
cat" doesn't seem to trigger the problem. Possibly I can do something  
crazy with setsid or similar? Dunno how to launch a pty from the  
command line...)

Thanks,

Rob
 1372940632.0


More information about the Toybox mailing list