From owner-freebsd-hackers Thu Jul 15 17:29:21 1999 Delivered-To: freebsd-hackers@freebsd.org Received: from dingo.cdrom.com (dingo.cdrom.com [204.216.28.145]) by hub.freebsd.org (Postfix) with ESMTP id A9E3315779 for ; Thu, 15 Jul 1999 17:29:19 -0700 (PDT) (envelope-from mike@dingo.cdrom.com) Received: from dingo.cdrom.com (localhost.cdrom.com [127.0.0.1]) by dingo.cdrom.com (8.9.3/8.8.8) with ESMTP id RAA02029; Thu, 15 Jul 1999 17:23:15 -0700 (PDT) (envelope-from mike@dingo.cdrom.com) Message-Id: <199907160023.RAA02029@dingo.cdrom.com> X-Mailer: exmh version 2.0.2 2/24/98 To: Warner Losh Cc: Mike Smith , freebsd-hackers@FreeBSD.ORG Subject: Re: OpenBSD's strlcpy(3) and strlcat(3) In-reply-to: Your message of "Thu, 15 Jul 1999 18:20:08 MDT." <199907160020.SAA01121@harmony.village.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Date: Thu, 15 Jul 1999 17:23:15 -0700 From: Mike Smith Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG > 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