Skip to contentSkip to conversation

block/curl.c: Refuse to open the handle for writes.

PATCH New Richard W.M. Jones 2 participants 3 messages Jun 10, 2013 Block layer

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 block/curl.c: Refuse to open the handle for writes.

This simple patch avoids a segfault in qemu if the user tries to open a curl disk for writing.

This was previously part of Fam Zheng's curl patch series, but it stands alone and we shouldn't forget about it.

Rich.

#1 lore raw

PATCH 1/1 block/curl.c: Refuse to open the handle for writes.

From: "Richard W.M. Jones" <[email protected]>

---
 block/curl.c | 4 ++++
 1 file changed, 4 insertions(+)
block/curl.c +4 -0
index b8935fd..f1e302b 100644
@@ -406,6 +406,10 @@ static int curl_open(BlockDriverState *bs, QDict *options, int flags)
 
     static int inited = 0;
 
+    if (flags & BDRV_O_RDWR) {
+        return -ENOTSUP;
+    }
+
     opts = qemu_opts_create_nofail(&runtime_opts);
     qemu_opts_absorb_qdict(opts, options, &local_err);
     if (error_is_set(&local_err)) {
Signature · 1 line
1.8.2.1
#2 lore raw

Am 10.06.2013 um 12:06 hat Richard W.M. Jones geschrieben:

Quoted 13 lines

From: "Richard W.M. Jones" <[email protected]>

---
 block/curl.c | 4 ++++
 1 file changed, 4 insertions(+)
block/curl.c +0 -0
index b8935fd..f1e302b 100644

block/curl.c static int curl_open(BlockDriverState *bs, QDict *options, int flags) · line 412

Quoted 7 lines
block/curl.c +4 -0
@@ -406,6 +406,10 @@ static int curl_open(BlockDriverState *bs, QDict *options, int flags)
 
     static int inited = 0;
 
+    if (flags & BDRV_O_RDWR) {
+        return -ENOTSUP;
+    }
+

Thanks, I applied this patch to the block branch for now, but I think a v2 with some better error reporting wouldn't hurt. We can either add a qerror_report() call or at least change the error code to -EROFS or something like that.

Kevin