ls -l segfault + [PATCH]

Denis Vlasenko vda.linux at googlemail.com
Mon Mar 19 20:59:51 UTC 2007


Thanks for excellent bug hunting!

On Monday 19 March 2007 14:52, Jan Evert van Grootheest wrote:
> > --- busybox-1.4.1/coreutils/ls.c.org    Mon Mar 19 14:00:13 2007
> > +++ busybox-1.4.1/coreutils/ls.c        Mon Mar 19 14:00:30 2007
> > @@ -792,7 +792,7 @@ int ls_main(int argc, char **argv)
> >         USE_FEATURE_AUTOWIDTH(char *terminal_width_str = NULL;)
> >         USE_FEATURE_LS_COLOR(char *color_opt;)
> > 
> > -       setvbuf(stdout, bb_common_bufsiz1, _IOFBF, BUFSIZ);
> > +       setvbuf(stdout, NULL, _IOFBF, 0);
> > 
> >  #if ENABLE_FEATURE_LS_TIMESTAMPS
> >         time(&current_time_t); 
> 
> Ok. So this is not enough. Using setvbuf with NULL does not fix it for me.
> 
> So it seems that the only real options are to remove the setvbuf or make ls not a safe applet.
> Back to the ash.c patch...

I will just remove setvbuf from ls.c. Committing to svn right now.

I mostly is worrying how to prevent such bugs from reappearing.

The problem is that it is very easy to forget that applet
is a safe one and thus whoever is hacking on it
should be extra careful.

Adding /* THIS IS A "SAFE" APPLET, BE CAREFUL! */
seems to be some sort of a solution, but I bet people will
overlook it.

Will try it with ls.c and see...
--
vda



More information about the busybox mailing list