use strlcpy, from openbsd

git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@12050 ec53bebd-3082-4978-b11e-865c3cabbd6b
This commit is contained in:
Love Hörnquist Åstrand
2003-04-16 16:28:03 +00:00
parent d1604b3dc5
commit 815445af73
3 changed files with 18 additions and 11 deletions

View File

@@ -251,11 +251,12 @@ getent(char **cap, size_t *len, char **db_array, int fd,
* Check if we have a top record from cgetset().
*/
if (depth == 0 && toprec != NULL && cgetmatch(toprec, name) == 0) {
if ((record = malloc (topreclen + BFRAG)) == NULL) {
size_t len = topreclen + BFRAG;
if ((record = malloc (len)) == NULL) {
errno = ENOMEM;
return (-2);
}
(void)strcpy(record, toprec); /* XXX: strcpy is safe */
(void)strlcpy(record, toprec, len);
db_p = db_array;
rp = record + topreclen + 1;
r_end = rp + BFRAG;