aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhilippe Mathieu-Daudé <philmd@redhat.com>2020-06-29 09:08:58 +0200
committerLaurent Vivier <laurent@vivier.eu>2020-07-07 12:38:50 +0200
commit8f4d9555823636c329cb40afc6f36969ec5d35e4 (patch)
tree7611f209465a4799e467d7a293ce5e972f7ed3a9
parent428a37770406346dac6d355a70ea5a8916aecb1f (diff)
downloadqemu-8f4d9555823636c329cb40afc6f36969ec5d35e4.zip
qemu-8f4d9555823636c329cb40afc6f36969ec5d35e4.tar.gz
qemu-8f4d9555823636c329cb40afc6f36969ec5d35e4.tar.bz2
util/qemu-option: Document the get_opt_value() function
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>
-rw-r--r--include/qemu/option.h13
1 files changed, 13 insertions, 0 deletions
diff --git a/include/qemu/option.h b/include/qemu/option.h
index eb40978..ac50d25 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,