Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 15 Jul 1999 18:26:36 -0600
From:      Warner Losh <imp@village.org>
To:        Mike Smith <mike@smith.net.au>
Cc:        Paul Hart <hart@iserver.com>, Julian Elischer <julian@whistle.com>, freebsd-hackers@FreeBSD.ORG
Subject:   Re: OpenBSD's strlcpy(3) and strlcat(3) 
Message-ID:  <199907160026.SAA01181@harmony.village.org>
In-Reply-To: Your message of "Thu, 15 Jul 1999 16:29:53 PDT." <199907152329.QAA01720@dingo.cdrom.com> 
References:  <199907152329.QAA01720@dingo.cdrom.com>  

next in thread | previous in thread | raw e-mail | index | archive | help
In message <199907152329.QAA01720@dingo.cdrom.com> Mike Smith writes:
: Ugh.  Take the first example in the paper; it rewrites as
: 
: 	len = asprintf(&path, "%s/.foorc");
: 
: as opposed to
: 
: 	strlcat(path, homedir, sizeof(path));
: 	strlcat(path, "/", sizeof(path));
: 	strlcat(path, ".foord", sizeof(path));
: 	len = strlen(path);
: 
: Yes, they're a better str*cat/cpy, but they're not the solution that 
: they claim to be.

You've forgotten the free(path) sometime later in your code...  That's
a can of warms you conveniently ignore...  And can be big problems for
library routines whose API is defined to return stuff into a static
buffer...

Warner


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?199907160026.SAA01181>