conf: Always pass an empty buffer to line_read() in get_dns()

Given that get_dns() touches the buffer read by line_read(), we
can't optimise that by passing the existing buffer.

Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
This commit is contained in:
Stefano Brivio 2021-10-20 00:01:35 +02:00
parent b0b77118fe
commit 7d24803fb3

3
conf.c
View file

@ -293,8 +293,7 @@ static void get_dns(struct ctx *c)
if ((fd = open("/etc/resolv.conf", O_RDONLY)) < 0) if ((fd = open("/etc/resolv.conf", O_RDONLY)) < 0)
goto out; goto out;
*buf = 0; while (!(*buf = 0) && line_read(buf, BUFSIZ, fd)) {
while (line_read(buf, BUFSIZ, fd)) {
if (!dns_set && strstr(buf, "nameserver ") == buf) { if (!dns_set && strstr(buf, "nameserver ") == buf) {
p = strrchr(buf, ' '); p = strrchr(buf, ' ');
if (!p) if (!p)