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

[Nbd] [PATCH] Don't check offset and length on a FLUSH command



See below, to be applied on top of the other patches.

Also at
http://git.alex.org.uk/
commits
065a1b241dde2ab6fe333ccf5bc057e7e327f8d4
8d4b9f4e3d10fdfa319b17f385eeaae775d0071c

--
Alex Bligh

Signed-Off-By: Alex Bligh <alex@...872...>

diff --git a/nbd-server.c b/nbd-server.c
index 602d42e..4122cef 100644
--- a/nbd-server.c
+++ b/nbd-server.c
@@ -1453,16 +1453,19 @@ int mainloop(CLIENT *client) {
(unsigned long long)request.from / 512, len);
#endif
               memcpy(reply.handle, request.handle, sizeof(reply.handle));
-               if ((request.from + len) > (OFFT_MAX)) {
-                       DEBUG("[Number too large!]");
-                       ERROR(client, reply, EINVAL);
-                       continue;
-               }

- if (((ssize_t)((off_t)request.from + len) > client->exportsize)) {
-                       DEBUG("[RANGE!]");
-                       ERROR(client, reply, EINVAL);
-                       continue;
+               if ((command==NBD_CMD_WRITE) || (command==NBD_CMD_READ)) {
+                       if ((request.from + len) > (OFFT_MAX)) {
+                               DEBUG("[Number too large!]");
+                               ERROR(client, reply, EINVAL);
+                               continue;
+                       }
+
+ if (((ssize_t)((off_t)request.from + len) > client->exportsize)) {
+                               DEBUG("[RANGE!]");
+                               ERROR(client, reply, EINVAL);
+                               continue;
+                       }
               }

               if (command==NBD_CMD_WRITE) {




Reply to: