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 2006-06-14 15:09:52 +00:00
parent dd28c26ad5
commit 99fa74bcc2

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