usage of strtok()

Alan DeKok aland at
Wed Jul 4 22:33:29 CEST 2007

Enrik Berkhan wrote:
> I've just noticed that strtok() is used in some places in FreeRADIUS,
> e.g. in rlm_perl for tokenizing the xlat() arguments. IIRC, strtok() is
> not thread safe.

  There are a bunch of standard C functions with completely broken API.

> What would be the best and most portable approach to avoid it? Use
> strtok_r() if available and/or fall back to a strtok_r implementation
> provided by FreeRADIUS like mystrtok() in src/lib/valuepair.c?

  I think using strtok_r would be best.  If it doesn't exist on a
system, it can be provided in src/lib/missing.c

  Alan DeKok.

More information about the Freeradius-Devel mailing list