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:
parent
fee8a46e77
commit
c11d5762c2
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=159605
@ -162,7 +162,8 @@ efgetln(FILE *fp, char **line)
|
|||||||
*line = malloc(rv + 1);
|
*line = malloc(rv + 1);
|
||||||
if (*line == NULL)
|
if (*line == NULL)
|
||||||
errx(1, "cannot allocate memory");
|
errx(1, "cannot allocate memory");
|
||||||
rv = strlcpy(*line, cp, rv + 1);
|
memcpy(*line, cp, rv);
|
||||||
|
(*line)[rv] = '\0';
|
||||||
}
|
}
|
||||||
assert(rv == strlen(*line));
|
assert(rv == strlen(*line));
|
||||||
return (rv);
|
return (rv);
|
||||||
|
Loading…
Reference in New Issue
Block a user