[BusyBox] skip_whitespace.c can segfault
Tito
farmatito at tiscali.it
Wed Mar 17 20:08:24 UTC 2004
On Wednesday 17 March 2004 15:20, you wrote:
> On Wed, Mar 17, 2004 at 04:18:22PM +0000, Tito wrote:
> > Hi to all,
> > I noticed that the bb_skip_whitespace() function can
> > segfault if the argument passed is NULL as can
>
> It wasn't meant to handled NULL args.
I just reported this because I've seen that more extensive error checking
is done in libb functions than in the standard ones.
> > I can't say if this is a treat for an experienced programmer,
> > but it could be fixed by modifying *bb_skip_whitespace(const char *s) to
> >
> > extern const char *bb_skip_whitespace(const char *s)
> > {
> > while ( s && isspace(*s)) {
> > ++s;
> > }
> >
> > return s;
> > }
>
> Ugh... For the moment, we'll assume that you'd want to catch NULL args
> (which I'm against unless you want to do so in an assert()). In your
> proposed solution, you are unnecessarily checking 's' in every iteration
> of the loop.
I never said that there is a not better solution than the one I've proposed... ;-)
Tito
>
> Manuel
>
>
More information about the busybox
mailing list