diff options
author | Eric Blake <eblake@redhat.com> | 2016-05-11 16:39:44 -0600 |
---|---|---|
committer | Paolo Bonzini <pbonzini@redhat.com> | 2016-06-16 18:39:05 +0200 |
commit | 943cec86d0864464ab29b42940c49d1ccbe8d268 (patch) | |
tree | 0edf2c73a1c3f3fee5a7f43cad329e5436618dcb /include | |
parent | f3c32fce3688fe1f13ceb0777faa1fc19d66d1fc (diff) | |
download | qemu-943cec86d0864464ab29b42940c49d1ccbe8d268.zip qemu-943cec86d0864464ab29b42940c49d1ccbe8d268.tar.gz qemu-943cec86d0864464ab29b42940c49d1ccbe8d268.tar.bz2 |
nbd: Avoid magic number for NBD max name size
Declare a constant and use that when determining if an export
name fits within the constraints we are willing to support.
Note that upstream NBD recently documented that clients MUST
support export names of 256 bytes (not including trailing NUL),
and SHOULD support names up to 4096 bytes. 4096 is a bit big
(we would lose benefits of stack-allocation of a name array),
and we already have other limits in place (for example, qcow2
snapshot names are clamped around 1024). So for now, just
stick to the required minimum, as that's easier to audit than
a full-scale support for larger names.
Signed-off-by: Eric Blake <eblake@redhat.com>
Message-Id: <1463006384-7734-12-git-send-email-eblake@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'include')
-rw-r--r-- | include/block/nbd.h | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/include/block/nbd.h b/include/block/nbd.h index 747bb0a..df1f804 100644 --- a/include/block/nbd.h +++ b/include/block/nbd.h @@ -77,6 +77,12 @@ 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. */ +#define NBD_MAX_NAME_SIZE 256 ssize_t nbd_wr_syncv(QIOChannel *ioc, struct iovec *iov, |