qemu-block
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH v3 1/4] nbd/server: Prefer heap over stack for parsing client


From: Eric Blake
Subject: Re: [PATCH v3 1/4] nbd/server: Prefer heap over stack for parsing client names
Date: Wed, 13 Nov 2019 20:59:47 -0600
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.1.1

On 11/13/19 8:46 PM, Eric Blake wrote:
As long as we limit NBD names to 256 bytes (the bare minimum permitted
by the standard), stack-allocation works for parsing a name received
from the client.  But as mentioned in a comment, we eventually want to
permit up to the 4k maximum of the NBD standard, which is too large
for stack allocation; so switch everything in the server to use heap
allocation.  For now, there is no change in actually supported name
length.

Signed-off-by: Eric Blake <address@hidden>
---
  include/block/nbd.h | 10 +++++-----
  nbd/server.c        | 25 +++++++++++++++----------
  2 files changed, 20 insertions(+), 15 deletions(-)

@@ -427,7 +431,7 @@ static void nbd_check_meta_export(NBDClient *client)
  static int nbd_negotiate_handle_export_name(NBDClient *client, bool no_zeroes,
                                              Error **errp)
  {
-    char name[NBD_MAX_NAME_SIZE + 1];
+    g_autofree char *name;

This needs to be:

g_autofree char *name = NULL;

--
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3226
Virtualization:  qemu.org | libvirt.org




reply via email to

[Prev in Thread] Current Thread [Next in Thread]