On 08/09/2017 06:40 AM, Markus Armbruster wrote: > Eric Blake <ebl...@redhat.com> writes: > >> When you build qga input manually like this: >> >> cmd = g_strdup_printf("{'execute': 'guest-file-write'," >> " 'arguments': {'handle': %" PRId64 "," >> " 'buf-b64': '%s' } }", id, enc); >> ret = qmp_fd(fixture->fd, cmd); >> g_free(cmd); >> >> you're responsible for escaping the interpolated values for JSON. >> Not done here, and therefore works only because the base64 encoding >> does not include % or '. >> >> As a bonus, this eliminates the last external caller using varargs >> for qmp_fd_send(); the next patch will simplify that interface to > > I'm blind... where? >
>> - cmd = g_strdup_printf("\xff{'execute': 'guest-sync-delimited'," >> - " 'arguments': {'id': %u } }", r); >> - qmp_fd_send(fixture->fd, cmd); >> - g_free(cmd); >> + qmp_fd_send(fixture->fd, "\xff"); Oh, the only old caller wasn't using varargs either. So none of the public callers were passing a format string containing %, making the ... in the public signature pointless (the next patch gets rid of it). I'll see what I can do to tweak the commit message. > > I was starting to type "opportunity to switch to the \377 used in > libqtest.c", but then I noticed that one will go away in the next > patch. Nevermind then. Really, I moved the special handling of \377 out of libqtest.c into a direct string passed to qmp_fd_send(), across the combination of 11+12/22. We used to have to special case it in libqtest.c, because all of our input was unconditionally taking the round trip of input string -> QObject -> output string; but once we can output a string directly without the round trip, we don't need the special casing. -- Eric Blake, Principal Software Engineer Red Hat, Inc. +1-919-301-3266 Virtualization: qemu.org | libvirt.org
signature.asc
Description: OpenPGP digital signature