On 6/14/19 4:54 PM, Eric Blake wrote:
Instead of repeating a check for valid reply headers in each
sub-state
machine, let's have a common helper function do all the
work. Additionally, a central location will make it easier to
uniformly capture any NBD_REP_ERR message payloads.
---
generator/generator | 8 +--
generator/states-newstyle-opt-go.c | 40 +++----------
.../states-newstyle-opt-set-meta-context.c | 39 ++-----------
generator/states-newstyle-opt-starttls.c | 31 ++--------
.../states-newstyle-opt-structured-reply.c | 28 ++-------
generator/states-newstyle.c | 58 +++++++++++++++++++
6 files changed, 86 insertions(+), 118 deletions(-)
Aargh - I need to finish running 'make check' before posting. This one
breaks tests/meta-base-allocation unless:
+++ b/generator/states-newstyle-opt-set-meta-context.c
@@ -139,21 +139,13 @@
return 0;
NEWSTYLE.OPT_SET_META_CONTEXT.RECV_REPLY:
- uint32_t len;
- const uint32_t maxpayload = sizeof h->sbuf.or.payload.context;
-
switch (recv_into_rbuf (h)) {
+++ b/generator/states-newstyle.c
@@ -16,6 +16,64 @@
+ case NBD_REP_META_CONTEXT:
+ if (len <= sizeof h->sbuf.or.payload.context.context.context_id ||
+ len > sizeof h->sbuf.or.payload.context.context) {
I fix this to be:
if (len <= sizeof h->sbuf.or.payload.context.context ||
len > sizeof h->sbuf.or.payload.context) {
--
Eric Blake, Principal Software Engineer
Red Hat, Inc. +1-919-301-3226
Virtualization:
qemu.org |
libvirt.org