From 7d24803fb3fc8063a76df52a86f569605d8ec7c5 Mon Sep 17 00:00:00 2001 From: Stefano Brivio Date: Wed, 20 Oct 2021 00:01:35 +0200 Subject: 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 --- conf.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'conf.c') diff --git a/conf.c b/conf.c index d7ddfd7..2fb58a7 100644 --- a/conf.c +++ b/conf.c @@ -293,8 +293,7 @@ static void get_dns(struct ctx *c) if ((fd = open("/etc/resolv.conf", O_RDONLY)) < 0) goto out; - *buf = 0; - while (line_read(buf, BUFSIZ, fd)) { + while (!(*buf = 0) && line_read(buf, BUFSIZ, fd)) { if (!dns_set && strstr(buf, "nameserver ") == buf) { p = strrchr(buf, ' '); if (!p) -- cgit v1.2.3