Busybox 1.1.0 tr problem

Rob Landley rob at landley.net
Wed Jan 18 08:37:39 PST 2006


On Wednesday 18 January 2006 05:21, m.pommerenke at avm.de wrote:
> Hi Henry,
>
> > # echo abc123 | busybox tr -d "[0-9]"
> > Segmentation fault (core dumped)
>
> we have fixed this already.

Cool, I'm glad somebody could reproduce it.

> 1) tr "[0-9]"   Segmentation fault (core dumped)

I'm still not getting this segfault.  What's your build environment?  (uclibc?  
gcc4?)

> 2) tr "\[0"     did not work

What was it supposed to do?

> I know it's a hack but it should work.
>
> The bb_process_escape_sequence function returns '\' if you use is on an
> expression like "\[".
> It behaves like this on every escape sequence not known.

I'd like to get this fixed, but I'm not quite sure I understand the problem 
yet.  (I've had taking a closer look at process_escape_sequence() on my todo 
list for a while, but I don't have a reproduction sequence for your problem.)

Hmmm...  According to svn the last time process_escpae_sequence.c was touched 
was 7/29/2004, which was before 1.00 shipped.  And if I'm going to change the 
behavior, I need to audit all the existing users of it...

> static unsigned int expand(const char *arg, register unsigned char *buffer)
> {
>       unsigned char *buffer_start = buffer;
>       int i, ac;

Could you send me a patch so I can see what changed?  Your comments imply it's 
just this:

>             /*--- pp_process_escape_sequence verhaelt sich fehlerhaft, wenn
> es nichst zu excapen gibt ---*/
>             *buffer = bb_process_escape_sequence(&arg);
>             if((*buffer == '\\') && (save != '\\')) { /* HACK */
>                 *buffer = save;
>             }

and this:

>                   if (*arg++ != '-') {
>                         /*--- *buffer++ = '['; ---*//* m.pommerenke at avm.de:
> war immer in der auswahl vorhanden */
>                         arg -= 1; /* m.pommerenke at avm.de: org 2 ==> dann
> aber endlosschleife */
>                         continue;
>                   }
>                   i = *arg++;
>                   ac = *arg++;
>                   while (i <= ac)
>                         *buffer++ = i++;
>                   arg++;                        /* Skip the assumed ']' */
>             } else if (*arg == ']') {  /* m.pommerenke at avm.de: war immer in
> der auswahl vorhanden */
>             *arg++;
>             } else
>                   *buffer++ = *arg++;
>       }

But icht sprecht keine deutsch, so I have no idea what the comments say.  
(Will ponder after lunch.)

Rob
-- 
Steve Ballmer: Innovation!  Inigo Montoya: You keep using that word.
I do not think it means what you think it means.


More information about the busybox mailing list