From mboxrd@z Thu Jan 1 00:00:00 1970 From: Stefano Brivio To: passt-dev@passt.top Subject: [PATCH 09/16] conf: False "Assign instead of compare" positive, CWE-481 Date: Tue, 05 Apr 2022 19:05:07 +0200 Message-ID: <20220405170514.2963773-10-sbrivio@redhat.com> In-Reply-To: <20220405170514.2963773-1-sbrivio@redhat.com> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="===============0023716474607313867==" --===============0023716474607313867== Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit This really just needs to be an assignment before line_read() -- turn it into a for loop. Reported by Coverity. Signed-off-by: Stefano Brivio --- conf.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/conf.c b/conf.c index ca44b30..2412fc6 100644 --- a/conf.c +++ b/conf.c @@ -288,7 +288,7 @@ static void get_dns(struct ctx *c) if ((fd = open("/etc/resolv.conf", O_RDONLY | O_CLOEXEC)) < 0) goto out; - while (!(*buf = 0) && line_read(buf, BUFSIZ, fd)) { + for (*buf = 0; line_read(buf, BUFSIZ, fd); *buf = 0) { if (!dns_set && strstr(buf, "nameserver ") == buf) { p = strrchr(buf, ' '); if (!p) -- 2.35.1 --===============0023716474607313867==--