RE: [PATCH] strtok --> strsep in framebuffer drivers (part 2)

Peter Kjellerstedt (peter.kjellerstedt@axis.com)
Thu, 25 Oct 2001 15:44:40 +0200


> -----Original Message-----
> From: Peter Wächtler [mailto:pwaechtler@loewe-komp.de]
> Sent: 25 October 2001 15:36
> To: René Scharfe
> Cc: Linus Torvalds; Linux Kernel Mailing List
> Subject: Re: [PATCH] strtok --> strsep in framebuffer drivers (part 2)
>
> René Scharfe wrote:
> >
> > Hello,
> >
> > I just noticed two framebuffer drivers with strtok calls
> > that somehow passed below my radar (cscope). Patch below
> > converts them, too. And it re-adds "ignore empty tokens"
> > functionalty, which I forgot about the last time. Please apply.
> >
> > René

[snip]

> > diff -Nur ../linux-2.4.13-pre6/drivers/video/riva/fbdev.c
> ./drivers/video/riva/fbdev.c
> > --- ../linux-2.4.13-pre6/drivers/video/riva/fbdev.c Tue
> Oct 23 22:13:43 2001
> > +++ ./drivers/video/riva/fbdev.c Tue Oct 23 23:31:33 2001
> > @@ -2046,6 +2046,8 @@
> > return 0;
> >
> > while (this_opt = strsep(&options, ",")) {
> > + if (!*this_opt)
> > + continue;
>
> NAME
> strsep - extract token from string
> [...]
> RETURN VALUE
> The strsep() function returns a pointer to the token, or
> NULL if delim is not found in stringp.
>
> If strsep returns NULL, and you dereference it -> Oops.
>
>
> ! if (!this_opt)
> continue;

If strsep() returns NULL, then the while-loop will terminate.
Thus this is already taken care of.

//Peter
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/