strcat+strcat+strcat == baaad
david at l8s.co.uk
Mon Dec 2 05:05:23 CST 2002
> I suggest implementing strlcat and strlcpy, as in OpenBSD. I can write
> them, but I'm not sure where to place them. They should either be
> inlined (as in - implemented in an include file as a static func), or in
> some library that will be linked (statically, I hope). Ideas?
Inlining them would (probably) be bad news. They are not
a completely trivial size (ie smaller than the call sequence)
and they are more likely to be resident in the Icache if they
They are useful though, and do what the programmer wanted
(unlike strncpy whose only point is that it doesn't overrun
the target buffer).
However in this case they aren't quite right!
len = strlcpy(buf, s0, buflen);
len += strlcpy(buf + len, s1, buflen - len)
len += strlcpy(buf + len, s2, buflen - len)
is slightly more complex than using my str_add().
The source for the functions can be grabbed from netbsd or freebsd.
David Laight: david at l8s.co.uk
More information about the wine-devel