> In message <[email protected]> Mike Smith writes:
> : if (strlen(buf) >= sizeof(buf))
> : return(error);
>
> This can never be true with the strl functions.... They don't run off
> the end, so strlen(buf) is always going to be < sizeof(buf) since it
> doesn't include the traling null.
I actually should have copied the original example from the paper,
which was disgustingly more verbose; I mistransposed it for the abovem
which should probably have been (strlen(buf) == (sizeof(buf) - 1)) or
similar.
They recommend using:
len = strlcpy(path, homedir, sizeof(path));
if (len >= sizeof(path))
return(ENAMETOOLONG)
etc.
I still think this is the wrong way to deal with the problem. 8)
--
\\ The mind's the standard \\ Mike Smith
\\ of the man. \\ [email protected]
\\ -- Joseph Merrick \\ [email protected]
To Unsubscribe: send mail to [email protected]
with "unsubscribe freebsd-hackers" in the body of the message