Opened 22 years ago

Last modified 22 years ago

#249 closed Bug report

Server: TransferSocket::OnSend missing a byte

Reported by: mrdoubleyou Owned by:
Priority: normal Component: Other
Keywords: Cc: mrdoubleyou, Tim Kosse
Component version: Operating system type:
Operating system version:

Description

in case numsent < numread, the remainder of the buffer
is copied to the beginning of the buffer. However, the
code as it is, will miss one byte, due to the incorrect +1.
This causes corrupt files on the receiving client.
Isn't it possible to use memcpy? or is this a problem as
the two ranges overlap?

else if (numsent<numread)
{ This should not happen, but handle it in case it
happens

why shouldn't this happen? send() is not garantueed

to send the specified

number of bytes, so this might very well happen, as

it most certainly

does on the XBOX
for (int i=0;i<(numread-numsent);i++)
{

m_pBuffer[i]=m_pBuffer[i+numsent+1];
m_pBuffer[i]=m_pBuffer[i+numsent];

}


m_nBufferPos=numread-numsent;

}

Change History (2)

comment:1 by mrdoubleyou, 22 years ago

instead of the for-loop, this also works and might be faster:
memmove(m_pBuffer, m_pBuffer + numsent, numread -
numsent);

comment:2 by Tim Kosse, 22 years ago

Thanks for reporting this bug.

The strange thing is, that numsent<numread did NEVER
happen during all my tests.
I've transferred hundreds of gigs back and forth during the last
big test on several machines, but all files were transferred
without corruption which means that numsent<numread did
never happen.

Note: See TracTickets for help on using tickets.