ls -l segfault + [PATCH]

Jan Evert van Grootheest Jan-Evert.van.Grootheest at Vialis.nl
Mon Mar 19 06:52:59 PDT 2007


> > > On Mon, Mar 19, 2007 at 01:49:46PM +0100, Jan Evert van 
> Grootheest 
> > > wrote:
> > > > I found the manual page a bit confusing, because it first
> > > says, just
> > > > above the flags section, that setvbuf may be used on any
> > > open stream.
> > > > While later on, at the end of the first paragraph below 
> the flags 
> > > > section, it is said that it must be done between opening
> > the stream
> > > > and the first action on it.
> > > 
> > > The POSIX and C standard say:
> > > The setvbuf() function may be used after the stream pointed to by 
> > > stream is associated with an open file but before any other 
> > > operation (other than an unsuccessful call to
> > > setvbuf()) is performed on the stream.
> > 
> > Right. So if we want to keep a fully buffered output (which I
> > think we do), the patch below would be the way to go. And ls 
> > would remain a safe applet.
> > 
> > This works just fine here.
> > 
> > -- Jan Evert
> 
> --- 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...

-- Jan Evert 
 
The information contained in this communication is confidential and may be legally privileged. It is intended solely for the use of the individual or entity to whom it is addressed and others authorised to receive it. If you are not the intended recipient you are hereby notified that any disclosure, copying, distribution or taking any action in reliance on the contents of this information is strictly prohibited and may be unlawful. Vialis is neither liable for the proper and complete transmission of the information contained in this communication nor for any delay in its receipt. 
 


More information about the busybox mailing list