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'.
This commit is contained in:
Maxim Konovalov 2006-06-14 15:09:52 +00:00
parent fee8a46e77
commit c11d5762c2
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=159605

View File

@ -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);