aboutsummaryrefslogtreecommitdiff
path: root/block.c
diff options
context:
space:
mode:
authorKevin Wolf <kwolf@redhat.com>2018-07-04 13:28:29 +0200
committerKevin Wolf <kwolf@redhat.com>2018-07-05 10:29:19 +0200
commit824808dd77821ceba05357cb1ee4069a6a95bebd (patch)
tree9c5718d645066bd179c898133c6eac1e68122314 /block.c
parentbfcc224e3cf04ee3fef0eb69984607b5764d9892 (diff)
downloadqemu-824808dd77821ceba05357cb1ee4069a6a95bebd.zip
qemu-824808dd77821ceba05357cb1ee4069a6a95bebd.tar.gz
qemu-824808dd77821ceba05357cb1ee4069a6a95bebd.tar.bz2
block: Don't silently truncate node names
If the user passes a too long node name string, we silently truncate it to fit into BlockDriverState.node_name, i.e. to 31 characters. Apart from surprising the user when the node has a different name than requested, this also bypasses the check for duplicate names, so that the same name can be assigned to multiple nodes. Fix this by just making too long node names an error. Reported-by: Peter Krempa <pkrempa@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Diffstat (limited to 'block.c')
-rw-r--r--block.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/block.c b/block.c
index 961ec97..ac8b3a3 100644
--- a/block.c
+++ b/block.c
@@ -1156,6 +1156,12 @@ static void bdrv_assign_node_name(BlockDriverState *bs,
goto out;
}
+ /* Make sure that the node name isn't truncated */
+ if (strlen(node_name) >= sizeof(bs->node_name)) {
+ error_setg(errp, "Node name too long");
+ goto out;
+ }
+
/* copy node name into the bs and insert it into the graph list */
pstrcpy(bs->node_name, sizeof(bs->node_name), node_name);
QTAILQ_INSERT_TAIL(&graph_bdrv_states, bs, node_list);