From: David Gibson <david@gibson.dropbear.id.au>
To: Stefano Brivio <sbrivio@redhat.com>
Cc: passt-dev@passt.top
Subject: Re: [PATCH 3/3] log: Match implicit va_start() with va_end() in vlogmsg()
Date: Wed, 8 Nov 2023 10:31:06 +1100 [thread overview]
Message-ID: <ZUrIuhmvVl4Tdpbm@zatzit> (raw)
In-Reply-To: <20231107122833.1673498-4-sbrivio@redhat.com>
[-- Attachment #1: Type: text/plain, Size: 1351 bytes --]
On Tue, Nov 07, 2023 at 01:28:33PM +0100, Stefano Brivio wrote:
> 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).
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 <sbrivio@redhat.com>
> ---
> 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) ||
--
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
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
prev parent reply other threads:[~2023-11-08 1:15 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-11-07 12:28 [PATCH 0/3] Minimal fixes for issues reported by static checkers Stefano Brivio
2023-11-07 12:28 ` [PATCH 1/3] netlink: Sequence numbers are actually 32 bits wide Stefano Brivio
2023-11-07 23:32 ` David Gibson
2023-11-07 12:28 ` [PATCH 2/3] port_fwd: Don't try to read bound ports from invalid file handles Stefano Brivio
2023-11-07 12:28 ` [PATCH 3/3] log: Match implicit va_start() with va_end() in vlogmsg() Stefano Brivio
2023-11-07 23:31 ` David Gibson [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=ZUrIuhmvVl4Tdpbm@zatzit \
--to=david@gibson.dropbear.id.au \
--cc=passt-dev@passt.top \
--cc=sbrivio@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://passt.top/passt
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for IMAP folder(s).