aboutsummaryrefslogtreecommitdiff
path: root/block/dirty-bitmap.c
diff options
context:
space:
mode:
authorEric Blake <eblake@redhat.com>2019-11-13 20:46:33 -0600
committerEric Blake <eblake@redhat.com>2019-11-18 16:01:34 -0600
commitcf7c49cf6aedb0486ca7ba7c32aa819fe51dadfb (patch)
treed22968feb61ad3cd6060605293ed8f1a9976d6b4 /block/dirty-bitmap.c
parent9d7ab222da5a9de61b34f26ec442d37ccdd18cf0 (diff)
bitmap: Enforce maximum bitmap name length
We document that for qcow2 persistent bitmaps, the name cannot exceed 1023 bytes. It is inconsistent if transient bitmaps do not have to abide by the same limit, and it is unlikely that any existing client even cares about using bitmap names this long. It's time to codify that ALL bitmaps managed by qemu (whether persistent in qcow2 or not) have a documented maximum length. Signed-off-by: Eric Blake <eblake@redhat.com> Message-Id: <20191114024635.11363-3-eblake@redhat.com> Reviewed-by: Maxim Levitsky <mlevitsk@redhat.com> Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
Diffstat (limited to 'block/dirty-bitmap.c')
-rw-r--r--block/dirty-bitmap.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/block/dirty-bitmap.c b/block/dirty-bitmap.c
index 4bbb251b2c..7039e82520 100644
--- a/block/dirty-bitmap.c
+++ b/block/dirty-bitmap.c
@@ -104,9 +104,15 @@ BdrvDirtyBitmap *bdrv_create_dirty_bitmap(BlockDriverState *bs,
assert(is_power_of_2(granularity) && granularity >= BDRV_SECTOR_SIZE);
- if (name && bdrv_find_dirty_bitmap(bs, name)) {
- error_setg(errp, "Bitmap already exists: %s", name);
- return NULL;
+ if (name) {
+ if (bdrv_find_dirty_bitmap(bs, name)) {
+ error_setg(errp, "Bitmap already exists: %s", name);
+ return NULL;
+ }
+ if (strlen(name) > BDRV_BITMAP_MAX_NAME_SIZE) {
+ error_setg(errp, "Bitmap name too long: %s", name);
+ return NULL;
+ }
}
bitmap_size = bdrv_getlength(bs);
if (bitmap_size < 0) {