[BusyBox] Bugfix for strings.c in busybox unstable

Tito farmatito at tiscali.it
Wed Feb 19 07:38:03 UTC 2003


Hi Erik,
I discovered a little malloc bug in strings.c for bbunstable.
If you do:
MALLOC_CHECK_=1
export MALLOC_CHECK_
./busybox strings -afo  miscutils/strings.o

you get:
[snip]
miscutils/strings.o:    3056 exit
free(): invalid pointer 0x8062550!
malloc: using debugging hooks

I think I forgot to count from zero here, so fix is simple ,see the diff.
The other fixes are esthetical and to turn two compiler warnings off:

/rep/busybox/miscutils/strings.c: In function `strings_main':
/rep/busybox/miscutils/strings.c:43: warning: `t' might be used uninitialized 
in this function
/rep/busybox/miscutils/strings.c:45: warning: `string' might be used 
uninitialized in this function

43c43
<       long    t, count;
---
>       long    t=0, count;
45c45
<       char *string;
---
>       char *string=NULL;
53c53
<                               opt++;
---
>                               opt+=1;
61,62c61
<                               opt++;
<                               opt++;
---
>                               opt+=2;
86c85
<               string=xmalloc(n);
---
>               string=xmalloc(n+1);

Please apply

Thanks
CIAO TITO




More information about the busybox mailing list