1
0
mirror of https://passt.top/passt synced 2024-12-22 13:45:32 +00:00

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:
Stefano Brivio 2021-10-20 11:39:08 +02:00
parent 9618d24700
commit a20626fb35

6
util.c
View File

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