diff options
| author | Eric Blake | 2019-11-14 03:46:32 +0100 |
|---|---|---|
| committer | Eric Blake | 2019-11-18 23:01:34 +0100 |
| commit | 9d7ab222da5a9de61b34f26ec442d37ccdd18cf0 (patch) | |
| tree | 3e9909533221eb61a13776d70b21ab0c05dc72f8 /include/block | |
| parent | qemu-coroutine-sleep: Silence Coverity warning (diff) | |
| download | qemu-9d7ab222da5a9de61b34f26ec442d37ccdd18cf0.tar.gz qemu-9d7ab222da5a9de61b34f26ec442d37ccdd18cf0.tar.xz qemu-9d7ab222da5a9de61b34f26ec442d37ccdd18cf0.zip | |
nbd/server: Prefer heap over stack for parsing client names
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 <eblake@redhat.com>
Message-Id: <20191114024635.11363-2-eblake@redhat.com>
[eblake: fix uninit variable compile failure]
Reviewed-by: Maxim Levitsky <mlevitsk@redhat.com>
Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
Diffstat (limited to 'include/block')
| -rw-r--r-- | include/block/nbd.h | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/include/block/nbd.h b/include/block/nbd.h index 316fd705a9..c306423dc8 100644 --- a/include/block/nbd.h +++ b/include/block/nbd.h @@ -226,11 +226,11 @@ enum { /* Maximum size of a single READ/WRITE data buffer */ #define NBD_MAX_BUFFER_SIZE (32 * 1024 * 1024) -/* Maximum size of an export name. The NBD spec requires 256 and - * suggests that servers support up to 4096, but we stick to only the - * required size so that we can stack-allocate the names, and because - * going larger would require an audit of more code to make sure we - * aren't overflowing some other buffer. */ +/* + * Maximum size of an export name. The NBD spec requires a minimum of + * 256 and recommends that servers support up to 4096; all users use + * malloc so we can bump this constant without worry. + */ #define NBD_MAX_NAME_SIZE 256 /* Two types of reply structures */ |
