From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from gandalf.ozlabs.org (mail.ozlabs.org [IPv6:2404:9400:2221:ea00::3]) by passt.top (Postfix) with ESMTPS id AE4A05A026D for ; Wed, 8 Nov 2023 02:15:32 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gibson.dropbear.id.au; s=201602; t=1699406129; bh=A88zLAt7rsx4U2h+VE8XT/JbpB0ZL/d8mDFvp5uEbao=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=dH07wM84+so114AvtITGUEaPak6NqGb0r+SZY+GJV5vVohERAZynOrbgGnXrBNg5f lWjSd+2XZ3/qjykoWMWmpGvTSvaRbqb/IIOLQvPlizAiZht0jtOl5xGOT9Id556oQ2 YFqTSxNRcT/SdeVzrhsEeXFYks2/iFnUEemGX3EQ= Received: by gandalf.ozlabs.org (Postfix, from userid 1007) id 4SQ6b50HHWz4x7q; Wed, 8 Nov 2023 12:15:29 +1100 (AEDT) Date: Wed, 8 Nov 2023 10:31:06 +1100 From: David Gibson To: Stefano Brivio Subject: Re: [PATCH 3/3] log: Match implicit va_start() with va_end() in vlogmsg() Message-ID: References: <20231107122833.1673498-1-sbrivio@redhat.com> <20231107122833.1673498-4-sbrivio@redhat.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="Vl1cq7qX1d0UX8zW" Content-Disposition: inline In-Reply-To: <20231107122833.1673498-4-sbrivio@redhat.com> Message-ID-Hash: WVJFRLMQC7QAVJAR2AFMXBBMI6NEONL3 X-Message-ID-Hash: WVJFRLMQC7QAVJAR2AFMXBBMI6NEONL3 X-MailFrom: dgibson@gandalf.ozlabs.org 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: passt-dev@passt.top 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: --Vl1cq7qX1d0UX8zW Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Tue, Nov 07, 2023 at 01:28:33PM +0100, Stefano Brivio wrote: > According to C99, 7.15.1: >=20 > 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 >=20 > 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). Oops. I'm pretty sure this one will cause real problems on some platforms. Well caught. > Fixes: c0426ff10bc9 ("log: Add vlogmsg()") > Signed-off-by: Stefano Brivio > --- > log.c | 2 ++ > 1 file changed, 2 insertions(+) >=20 > 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); > } > =20 > if ((setlogmask(0) & LOG_MASK(LOG_DEBUG) && log_file =3D=3D -1) || --=20 David Gibson | I'll have my music baroque, and my code david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_ | _way_ _around_! http://www.ozlabs.org/~dgibson --Vl1cq7qX1d0UX8zW Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAEBCAAdFiEEO+dNsU4E3yXUXRK2zQJF27ox2GcFAmVKyKoACgkQzQJF27ox 2GeGgw//aRarBf4UGioNeVvCz1qEQ0Yo8lJQXUzBF4F+Or9X0CGZu2x8CsaBCRUn AKuOMr/TjF5VjmypM9pqtfd28WGFMKnzTnxVxJxxATkXyw7uCbkeieKNhsQ0YAYi Ij0t5NLJXDrBNNy4T/JFzilsiPFwEgZPKDi4p6/ipWkvkOwuTCoZn0DiO2iaiv5b xvpJyGfnXyQB+MHg/a2fU2jHwwD1GhopPjTbmidyKT3oBWpVOljvZfzD+H0sCRZM m1QInqrMhIfZSty/SsvAekU0oyYTuQYO1mLPPyPAdGpeWiMd5rRK3ixNIYu+oces bOlC0GEB2/YBx75rHd7HNOmiHuuZhGuVceIEPgUdyy0Jubd1Qa+fFmi9WHheM8Sb kDn7gkStm0zXgzOCqCc6e43gGqiS0BTDgm7V/OANtK/FJp9kVBytzkNkjqAsazNU Gc8cmL3UdVrSVI2DtvWtlaT9KCAAOGGlgnLlQNYXxS17L/D6+lqK/JRTPD5y+IrI Vl9kQMSjT74frDo+tmWmLFXUHBDbCng2fpnI2n5OKLpC5WUpuS1hb/89Ei5ONwvQ mR0GxHE/OBYSOOGc5YCJdgcMMIjSHIn4WSbMLHg+g36mkJ6pCp2pVdTNXlQd47LW sATQn3/ztc9dayjMhnmV6VBwt/N9kEPgDsJmWy0RaqMMBVa5PqU= =5L1g -----END PGP SIGNATURE----- --Vl1cq7qX1d0UX8zW--