From: Markus Armbruster <armbru@redhat.com>
To: Eric Blake <eblake@redhat.com>
Cc: qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH 4/5] qtest: Avoid passing raw strings through hmp()
Date: Thu, 20 Jul 2017 12:03:50 +0200 [thread overview]
Message-ID: <87a83zmnll.fsf@dusky.pond.sub.org> (raw)
In-Reply-To: <20170714190827.4083-5-eblake@redhat.com> (Eric Blake's message of "Fri, 14 Jul 2017 14:08:26 -0500")
Eric Blake <eblake@redhat.com> writes:
> The next patch will add __attribute__((__format__)) to hmp(), which
> in turn causes gcc to warn about non-literal format strings. Rather
> than risk an arbitrary string containing % being mis-handled, always
> pass variable strings along with a %s format.
More importantly (for me), "%s" makes correctness locally obvious.
Before the patch, I have to prove the argument can't contain '%'.
> Signed-off-by: Eric Blake <eblake@redhat.com>
> ---
> tests/test-hmp.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/tests/test-hmp.c b/tests/test-hmp.c
> index d77b3c8..0af0664 100644
> --- a/tests/test-hmp.c
> +++ b/tests/test-hmp.c
> @@ -80,7 +80,7 @@ static void test_commands(void)
> if (verbose) {
> fprintf(stderr, "\t%s\n", hmp_cmds[i]);
> }
> - response = hmp(hmp_cmds[i]);
> + response = hmp("%s", hmp_cmds[i]);
> g_free(response);
> }
>
> @@ -103,7 +103,7 @@ static void test_info_commands(void)
> if (verbose) {
> fprintf(stderr, "\t%s\n", info);
> }
> - resp = hmp(info);
> + resp = hmp("%s", info);
> g_free(resp);
> /* And move forward to the next line */
> info = strchr(endp + 1, '\n');
Reviewed-by: Markus Armbruster <armbru@redhat.com>
next prev parent reply other threads:[~2017-07-20 10:03 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-07-14 19:08 [Qemu-devel] [PATCH 0/5] random qapi cleanups Eric Blake
2017-07-14 19:08 ` [Qemu-devel] [PATCH 1/5] qapi: Further enhance visitor virtual walk doc example Eric Blake
2017-07-20 9:05 ` Markus Armbruster
2017-07-20 20:21 ` Eric Blake
2017-07-14 19:08 ` [Qemu-devel] [PATCH 2/5] tests: Enhance qobject output to cover partial visit Eric Blake
2017-07-20 9:52 ` Markus Armbruster
2017-07-20 20:27 ` Eric Blake
2017-07-14 19:08 ` [Qemu-devel] [PATCH 3/5] qapi: Visitor documentation tweak Eric Blake
2017-07-20 10:00 ` Markus Armbruster
2017-07-20 20:28 ` Eric Blake
2017-07-14 19:08 ` [Qemu-devel] [PATCH 4/5] qtest: Avoid passing raw strings through hmp() Eric Blake
2017-07-20 10:03 ` Markus Armbruster [this message]
2017-07-14 19:08 ` [Qemu-devel] [PATCH 5/5] qtest: Document calling conventions Eric Blake
2017-07-20 10:10 ` Markus Armbruster
2017-07-20 20:37 ` Eric Blake
2017-07-20 20:53 ` Eric Blake
2017-07-21 6:42 ` Markus Armbruster
2017-07-21 12:08 ` Eric Blake
2017-07-21 14:13 ` Markus Armbruster
2017-07-18 16:09 ` [Qemu-devel] [PATCH 0/5] random qapi cleanups Markus Armbruster
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=87a83zmnll.fsf@dusky.pond.sub.org \
--to=armbru@redhat.com \
--cc=eblake@redhat.com \
--cc=qemu-devel@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.