[BusyBox] skip_whitespace.c can segfault
Manuel Novoa III
mjn3 at codepoet.org
Wed Mar 17 15:20:45 UTC 2004
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 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.
Manuel
More information about the busybox
mailing list