Skip to contentSkip to conversation

qcow2: Prevent backing file names longer than 1023

PATCH Applied Max Reitz 2 participants 2 messages Apr 6, 2016 – Apr 8, 2016 Block layer

lore
Share & tools
lore

Max Reitz

author
#0 lore raw

PATCH v2 1/1 qcow2: Prevent backing file names longer than 1023

We reject backing file names with a length of more than 1023 characters when opening a qcow2 file, so we should not produce such files ourselves.

---
v2:
- Move the check to qcow2_change_backing_file() so the BDS state will not be modified if that condition is not met [Kevin]

---
 block/qcow2.c | 4 ++++
 1 file changed, 4 insertions(+)
block/qcow2.c +4 -0
index 056525c..470734b 100644
@@ -1986,6 +1986,10 @@ static int qcow2_change_backing_file(BlockDriverState *bs,
 {
     BDRVQcow2State *s = bs->opaque;
 
+    if (backing_file && strlen(backing_file) > 1023) {
+        return -EINVAL;
+    }
+
     pstrcpy(bs->backing_file, sizeof(bs->backing_file), backing_file ?: "");
     pstrcpy(bs->backing_format, sizeof(bs->backing_format), backing_fmt ?: "");
 
Signature · 1 line
2.8.0
Applied
#1 lore raw

Am 06.04.2016 um 18:32 hat Max Reitz geschrieben:

Quoted 6 lines

We reject backing file names with a length of more than 1023 characters when opening a qcow2 file, so we should not produce such files ourselves.

Thanks, applied to the block branch.

Kevin