BUG: read-command with data size 0 does not return a response header
authorfolkert <folkert@vanheusden.com>
Mon, 4 Mar 2013 15:29:23 +0000 (16:29 +0100)
committerWouter Verhelst <w@uter.be>
Wed, 6 Mar 2013 12:09:57 +0000 (13:09 +0100)
NBD-server v3.2 has a problem: if a client does a read-request of 0
bytes in length, then the nbd-server does not return a response header.
This is not in line with a write request which always returns a response
header.
This patch solves that behaviour.

nbd-server.c

index 9408a5b0a2e57e1b0dca857bd66e9869362f19ce..feb959e64aaee391b3e2e96008cf9ada9a9aed91 100644 (file)
@@ -1839,11 +1839,11 @@ int mainloop(CLIENT *client) {
 
                case NBD_CMD_READ:
                        DEBUG("exp->buf, ");
-                       memcpy(buf, &reply, sizeof(struct nbd_reply));
                        if (client->transactionlogfd != -1)
                                writeit(client->transactionlogfd, &reply, sizeof(reply));
-                       p = buf + sizeof(struct nbd_reply);
-                       writelen = currlen + sizeof(struct nbd_reply);
+                       writeit(client->net, &reply, sizeof(reply));
+                       p = buf;
+                       writelen = currlen;
                        while(len > 0) {
                                if (expread(request.from, p, currlen, client)) {
                                        DEBUG("Read failed: %m");