From 99fa74bcc24b8d061baa61cf998edf7553bac15c Mon Sep 17 00:00:00 2001 From: maxim Date: Wed, 14 Jun 2006 15:09:52 +0000 Subject: [PATCH] o Revert a previous delta as strlcpy(3) operates with NUL-terminated strings and cp is not. Fix logic in the original code and eliminate core dumps on lines without '\n'. --- sbin/devfs/devfs.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sbin/devfs/devfs.c b/sbin/devfs/devfs.c index b232f2a561bc..0e7b66210121 100644 --- a/sbin/devfs/devfs.c +++ b/sbin/devfs/devfs.c @@ -162,7 +162,8 @@ efgetln(FILE *fp, char **line) *line = malloc(rv + 1); if (*line == NULL) errx(1, "cannot allocate memory"); - rv = strlcpy(*line, cp, rv + 1); + memcpy(*line, cp, rv); + (*line)[rv] = '\0'; } assert(rv == strlen(*line)); return (rv);