[AFD]: Fix read data corruption when peeking at network data (TDI_RECEIVE_PEEK is...
authorCameron Gutman <aicommander@gmail.com>
Sun, 1 Aug 2010 23:42:33 +0000 (23:42 +0000)
committerCameron Gutman <aicommander@gmail.com>
Sun, 1 Aug 2010 23:42:33 +0000 (23:42 +0000)
svn path=/trunk/; revision=48403

reactos/drivers/network/afd/afd/read.c

index cf2133e..3666627 100644 (file)
@@ -80,7 +80,7 @@ static VOID RefillSocketBuffer( PAFD_FCB FCB ) {
 static NTSTATUS TryToSatisfyRecvRequestFromBuffer( PAFD_FCB FCB,
                                                                                                   PAFD_RECV_INFO RecvReq,
                                                                                                   PUINT TotalBytesCopied ) {
 static NTSTATUS TryToSatisfyRecvRequestFromBuffer( PAFD_FCB FCB,
                                                                                                   PAFD_RECV_INFO RecvReq,
                                                                                                   PUINT TotalBytesCopied ) {
-    UINT i, BytesToCopy = 0,
+    UINT i, BytesToCopy = 0, FcbBytesCopied = FCB->Recv.BytesUsed;
                BytesAvailable =
                FCB->Recv.Content - FCB->Recv.BytesUsed;
     PAFD_MAPBUF Map;
                BytesAvailable =
                FCB->Recv.Content - FCB->Recv.BytesUsed;
     PAFD_MAPBUF Map;
@@ -115,12 +115,13 @@ static NTSTATUS TryToSatisfyRecvRequestFromBuffer( PAFD_FCB FCB,
                                                                        BytesToCopy));
 
                        RtlCopyMemory( Map[i].BufferAddress,
                                                                        BytesToCopy));
 
                        RtlCopyMemory( Map[i].BufferAddress,
-                                                  FCB->Recv.Window + FCB->Recv.BytesUsed,
+                                                  FCB->Recv.Window + FcbBytesCopied,
                                                   BytesToCopy );
 
                        MmUnmapLockedPages( Map[i].BufferAddress, Map[i].Mdl );
 
             *TotalBytesCopied += BytesToCopy;
                                                   BytesToCopy );
 
                        MmUnmapLockedPages( Map[i].BufferAddress, Map[i].Mdl );
 
             *TotalBytesCopied += BytesToCopy;
+                       FcbBytesCopied += BytesToCopy;
 
             if (!(RecvReq->TdiFlags & TDI_RECEIVE_PEEK)) {
                 FCB->Recv.BytesUsed += BytesToCopy;
 
             if (!(RecvReq->TdiFlags & TDI_RECEIVE_PEEK)) {
                 FCB->Recv.BytesUsed += BytesToCopy;