util: Go to next non-empty line, skip newlines in line_read()
Otherwise, we'll stop returning lines at the first empty line in a file -- this is not expected in case of e.g. /etc/resolv.conf. Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
This commit is contained in:
parent
9618d24700
commit
a20626fb35
1 changed files with 5 additions and 1 deletions
6
util.c
6
util.c
|
@ -405,7 +405,11 @@ char *line_read(char *buf, size_t len, int fd)
|
|||
|
||||
buf[len] = 0;
|
||||
|
||||
if (!(p = strchr(buf, '\n')))
|
||||
p = buf;
|
||||
while (*p == '\n' && strlen(p) && (size_t)(p - buf) < len)
|
||||
p++;
|
||||
|
||||
if (!(p = strchr(p, '\n')))
|
||||
return buf;
|
||||
|
||||
*p = 0;
|
||||
|
|
Loading…
Reference in a new issue