bug-glibc
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: strtok() segfault


From: Andreas Jaeger
Subject: Re: strtok() segfault
Date: 22 Feb 2001 21:27:11 +0100
User-agent: Gnus/5.090001 (Oort Gnus v0.01) XEmacs/21.1 (Channel Islands)

Hi,

we've just fixed this bug yesterday for the i686 case (check CVS for a
patch).

Fumitoshi UKAI <address@hidden> writes:

> Hi,
> 
> While I'm building and testing w3mmee, a text web browser based on w3m
> written by Akinori ITO, Kiyokazu SUTO and others, I got segfault from
> latest w3mmee.  I looked into this problem and I found the reason of
> this is in strtok().

[...]
> 
> In this example, if first three of strtok(NULL, " \n\t\r") is removed,
> last call of strtok(NULL, " \n\t\r") will return "def", which is not
> subsequent search of "\n"!
> 
> I think this can be fixed by the following patch:
> 
> --- sysdeps/generic/strtok.c.orig       Wed Aug 16 03:16:25 2000        
> +++ sysdeps/generic/strtok.c    Fri Feb 23 03:40:41 2001
> @@ -44,8 +44,10 @@
>  
>    /* Scan leading delimiters.  */
>    s += strspn (s, delim);
> -  if (*s == '\0')
> +  if (*s == '\0') {
> +    olds = s;
>      return NULL;
> +  }
>  
>    /* Find the end of the token.  */
>    token = s;
> 
> Of course, it should be applied for sysdeps/generic/strtok_r.c.

That looks fine.  Uli, shall I commit the patch to both places?

> And same logic might be needed in sysdeps/i386/{strtok.S,strtok_r.S}

I'm not sure about i386, Uli, can you double check the assembler,
please?

> Or, is such use of strtok(), that is call strtok(NULL, "...") after
> strtok() return NULL, illegal?

It's legal usage.

Thanks,
Andreas
-- 
 Andreas Jaeger
  SuSE Labs address@hidden
   private address@hidden
    http://www.suse.de/~aj



reply via email to

[Prev in Thread] Current Thread [Next in Thread]