From mboxrd@z Thu Jan 1 00:00:00 1970 Received: by passt.top (Postfix, from userid 1000) id 1153F5A0275; Tue, 7 Nov 2023 13:28:33 +0100 (CET) From: Stefano Brivio To: passt-dev@passt.top Subject: [PATCH 3/3] log: Match implicit va_start() with va_end() in vlogmsg() Date: Tue, 7 Nov 2023 13:28:33 +0100 Message-Id: <20231107122833.1673498-4-sbrivio@redhat.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231107122833.1673498-1-sbrivio@redhat.com> References: <20231107122833.1673498-1-sbrivio@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Message-ID-Hash: L4YGZVSVBUSUMJYVL2SLA75VTZZXVK7P X-Message-ID-Hash: L4YGZVSVBUSUMJYVL2SLA75VTZZXVK7P X-MailFrom: sbrivio@passt.top X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: David Gibson X-Mailman-Version: 3.3.8 Precedence: list List-Id: Development discussion and patches for passt Archived-At: Archived-At: List-Archive: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: According to C99, 7.15.1: Each invocation of the va_start and va_copy macros shall be matched by a corresponding invocation of the va_end macro in the same function and the same applies to C11. I still have to come across a platform where va_end() actually does something, but thus spake the standard. This would be reported by Coverity as "Missing varargs init or cleanup" (CWE-573). Fixes: c0426ff10bc9 ("log: Add vlogmsg()") Signed-off-by: Stefano Brivio --- log.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/log.c b/log.c index 95c4fa4..b206f72 100644 --- a/log.c +++ b/log.c @@ -67,6 +67,8 @@ void vlogmsg(int pri, const char *format, va_list ap) logfile_write(pri, format, ap2); else if (!(setlogmask(0) & LOG_MASK(LOG_DEBUG))) passt_vsyslog(pri, format, ap2); + + va_end(ap2); } if ((setlogmask(0) & LOG_MASK(LOG_DEBUG) && log_file == -1) || -- 2.39.2