qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [RFC PATCH 51/56] block/nfs: Fix for readahead-size, page-c


From: Markus Armbruster
Subject: [Qemu-devel] [RFC PATCH 51/56] block/nfs: Fix for readahead-size, page-cache-size > INT64_MAX
Date: Mon, 7 Aug 2017 16:45:55 +0200

nfs_client_open() implicitly converts the uint64_t value of
qemu_opt_get_number() to int64_t, then clamps it to range.  The
clamping is broken for negative values.

Fix by making NFSClient members @readahead and @pagecache uint64_t.

Signed-off-by: Markus Armbruster <address@hidden>
---
 block/nfs.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/block/nfs.c b/block/nfs.c
index d8db419..2776788 100644
--- a/block/nfs.c
+++ b/block/nfs.c
@@ -58,7 +58,8 @@ typedef struct NFSClient {
     bool cache_used;
     NFSServer *server;
     char *path;
-    int64_t uid, gid, tcp_syncnt, readahead, pagecache, debug;
+    int64_t uid, gid, tcp_syncnt, debug;
+    uint64_t readahead, pagecache;
 } NFSClient;
 
 typedef struct NFSRPC {
@@ -856,10 +857,10 @@ static void nfs_refresh_filename(BlockDriverState *bs, 
QDict *options)
         qdict_put_int(opts, "tcp-syn-cnt", client->tcp_syncnt);
     }
     if (client->readahead) {
-        qdict_put_int(opts, "readahead-size", client->readahead);
+        qdict_put_uint(opts, "readahead-size", client->readahead);
     }
     if (client->pagecache) {
-        qdict_put_int(opts, "page-cache-size", client->pagecache);
+        qdict_put_uint(opts, "page-cache-size", client->pagecache);
     }
     if (client->debug) {
         qdict_put_int(opts, "debug", client->debug);
-- 
2.7.5




reply via email to

[Prev in Thread] Current Thread [Next in Thread]