Date: Thu, 15 Jul 1999 17:23:15 -0700 From: Mike Smith <mike@smith.net.au> To: Warner Losh <imp@village.org> Cc: Mike Smith <mike@smith.net.au>, freebsd-hackers@FreeBSD.ORG Subject: Re: OpenBSD's strlcpy(3) and strlcat(3) Message-ID: <199907160023.RAA02029@dingo.cdrom.com> In-Reply-To: Your message of "Thu, 15 Jul 1999 18:20:08 MDT." <199907160020.SAA01121@harmony.village.org>
next in thread | previous in thread | raw e-mail | index | archive | help
> In message <199907152358.QAA01894@dingo.cdrom.com> 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. \\ msmith@freebsd.org \\ -- Joseph Merrick \\ msmith@cdrom.com To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199907160023.RAA02029>