]> git.hungrycats.org Git - linux/commitdiff
[PATCH] ncpfs data corruption when using large TCP transfers
authorPetr Vandrovec <vandrove@vc.cvut.cz>
Thu, 6 May 2004 03:22:19 +0000 (20:22 -0700)
committerLinus Torvalds <torvalds@ppc970.osdl.org>
Thu, 6 May 2004 03:22:19 +0000 (20:22 -0700)
ncpfs was forgetting to update iovec's iov_base field whenever partial
transmission occured. This was causing data corruption during large
(60kB) writes.

The code now also passes copy of iovec to the sock_sendmsg, so it does
not rely on network stack updating (or not updating) passed iovec in
case of success (or failure).

fs/ncpfs/sock.c

index 5aa23416d5a947b7e178c426ac022ff8f2f6a60b..4d49900d45978802740a4e0e4f874c8cec889cff 100644 (file)
@@ -205,6 +205,7 @@ static void __ncptcp_try_send(struct ncp_server *server) {
        struct ncp_request_reply *rq;
        struct msghdr msg;
        struct iovec* iov;
+       struct iovec iovc[3];
        int result;
 
        rq = server->tx.creq;
@@ -212,10 +213,12 @@ static void __ncptcp_try_send(struct ncp_server *server) {
                return;
        }
 
+       /* sock_sendmsg updates iov pointers for us :-( */
+       memcpy(iovc, rq->tx_ciov, rq->tx_iovlen * sizeof(iov[0]));
        msg.msg_name = NULL;
        msg.msg_namelen = 0;
        msg.msg_control = NULL;
-       msg.msg_iov = rq->tx_ciov;
+       msg.msg_iov = iovc;
        msg.msg_iovlen = rq->tx_iovlen;
        msg.msg_flags = MSG_NOSIGNAL | MSG_DONTWAIT;
        result = sock_sendmsg(server->ncp_sock, &msg, rq->tx_totallen);
@@ -239,6 +242,7 @@ static void __ncptcp_try_send(struct ncp_server *server) {
                iov++;
                rq->tx_iovlen--;
        }
+       iov->iov_base += result;
        iov->iov_len -= result;
        rq->tx_ciov = iov;
 }