[Libguestfs] [libnbd PATCH 3/7] states: Allow large SET_CONTEXT_NAME replies

Eric Blake eblake at redhat.com
Fri Jun 14 21:53:59 UTC 2019


Although commit 5cc2547f rejects strings that are too long to send
over the protocol, it does not prevent the user from requesting a
context string longer than what we can store in sbuf. If the server
supports such a long context string, we end up blindly skipping the
server's reply as being oversized, and the user can't access that
context even though the server was happy to support it.

Of course, in practice, the only known contexts in existing servers
are not that long. But since we just recently enlarged struct
nbd_handle to support capture of the server's error messages on
structured replies, we might as well reuse that space to also capture
the full width of any possible context name.
---
 lib/internal.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/internal.h b/lib/internal.h
index 6750938..5f19279 100644
--- a/lib/internal.h
+++ b/lib/internal.h
@@ -125,7 +125,7 @@ struct nbd_handle {
         struct nbd_fixed_new_option_reply_info_export export;
         struct {
           struct nbd_fixed_new_option_reply_meta_context context;
-          char str[64];
+          char str[NBD_MAX_STRING];
         }  __attribute__((packed)) context;
       } payload;
     }  __attribute__((packed)) or;
-- 
2.20.1




More information about the Libguestfs mailing list