From: Laurent Vivier <laurent@vivier.eu>
To: qemu-devel@nongnu.org
Cc: qemu-trivial@nongnu.org,
"Philippe Mathieu-Daudé" <philmd@redhat.com>,
"Daniel P . Berrangé" <berrange@redhat.com>,
"Michael Tokarev" <mjt@tls.msk.ru>,
"Laurent Vivier" <laurent@vivier.eu>
Subject: [PULL 5/7] util/qemu-option: Document the get_opt_value() function
Date: Tue, 7 Jul 2020 12:52:53 +0200 [thread overview]
Message-ID: <20200707105255.362318-6-laurent@vivier.eu> (raw)
In-Reply-To: <20200707105255.362318-1-laurent@vivier.eu>
From: Philippe Mathieu-Daudé <philmd@redhat.com>
Coverity noticed commit 950c4e6c94 introduced a dereference before
null check in get_opt_value (CID1391003):
In get_opt_value: All paths that lead to this null pointer
comparison already dereference the pointer earlier (CWE-476)
We fixed this in commit 6e3ad3f0e31, but relaxed the check in commit
0c2f6e7ee99 because "No callers of get_opt_value() pass in a NULL
for the 'value' parameter".
Since this function is publicly exposed, it risks new users to do
the same error again. Avoid that documenting the 'value' argument
must not be NULL.
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Message-Id: <20200629070858.19850-1-philmd@redhat.com>
Signed-off-by: Laurent Vivier <laurent@vivier.eu>
---
include/qemu/option.h | 13 +++++++++++++
1 file changed, 13 insertions(+)
diff --git a/include/qemu/option.h b/include/qemu/option.h
index eb4097889d52..ac50d257746a 100644
--- a/include/qemu/option.h
+++ b/include/qemu/option.h
@@ -28,6 +28,19 @@
#include "qemu/queue.h"
+/**
+ * get_opt_value
+ * @p: a pointer to the option name, delimited by commas
+ * @value: a non-NULL pointer that will received the delimited options
+ *
+ * The @value char pointer will be allocated and filled with
+ * the delimited options.
+ *
+ * Returns the position of the comma delimiter/zero byte after the
+ * option name in @p.
+ * The memory pointer in @value must be released with a call to g_free()
+ * when no longer required.
+ */
const char *get_opt_value(const char *p, char **value);
void parse_option_size(const char *name, const char *value,
--
2.26.2
next prev parent reply other threads:[~2020-07-07 10:58 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-07-07 10:52 [PULL 0/7] Trivial branch for 5.1 patches Laurent Vivier
2020-07-07 10:52 ` [PULL 1/7] fix the prototype of muls64/mulu64 Laurent Vivier
2020-07-07 10:52 ` [PULL 2/7] trivial: Respect alphabetical order of .o files in Makefile.objs Laurent Vivier
2020-07-07 10:52 ` [PULL 3/7] .mailmap: Update Alexander Graf email address Laurent Vivier
2020-07-07 10:52 ` [PULL 4/7] MAINTAINERS: Update Radoslaw Biernacki " Laurent Vivier
2020-07-07 10:52 ` Laurent Vivier [this message]
2020-07-07 10:52 ` [PULL 6/7] intel_iommu: "aw-bits" error message still refers to "x-aw-bits" Laurent Vivier
2020-07-07 10:52 ` [PULL 7/7] net/tap-solaris.c: Include qemu-common.h for TFR macro Laurent Vivier
2020-07-09 15:49 ` [PULL 0/7] Trivial branch for 5.1 patches Peter Maydell
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=20200707105255.362318-6-laurent@vivier.eu \
--to=laurent@vivier.eu \
--cc=berrange@redhat.com \
--cc=mjt@tls.msk.ru \
--cc=philmd@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=qemu-trivial@nongnu.org \
/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.
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 NNTP newsgroup(s).